← Back
Cloudflare AI Worker
🌐
Problem
AI APIs are slow for users far from the provider's servers. A user in Tokyo hitting OpenAI's US servers sees 200ms+ of network latency before processing even starts.
Solution
An edge-deployed API gateway running in 300+ Cloudflare locations worldwide.
- Low latency: Connect to nearest edge location
- Multi-provider: Route to OpenAI, Claude, or Cloudflare AI
- Rate limiting: Built-in abuse protection
- Caching: Instant responses for repeated queries
Demo
Deploy the worker. Hit the /chat endpoint from different global locations. Compare latency vs hitting OpenAI directly. Show rate limiting kicking in after threshold.
Deploy to edge
Compare latency
Run it
git clone https://github.com/freshveejay/cloudflare-ai-worker
cd cloudflare-ai-worker
npm install
wrangler dev
# Deploy: wrangler publish