cloudflare-worker-api-proxylisted
Install: claude install-skill shali10/awesome-agent-skills
# Zero-Cost Serverless OpenAI API Proxy on Cloudflare Workers
## Overview
A high-performance, edge-native API proxy deployed on Cloudflare Workers. It enables zero-cost routing, token authentication, custom rate-limiting, and header rewriting for OpenAI, Claude, and Google Gemini API endpoints, bypassing regional network blocks with global edge caching and SSE streaming support.
## When to Use & When NOT to Use
### When to Use
- Bypassing geographic IP restrictions on AI provider APIs (e.g. OpenAI / Anthropic).
- Adding custom Bearer token authentication in front of self-hosted or shared LLM gateways.
- Injecting custom user agents or security headers into upstream requests.
### When NOT to Use
- Heavy video/audio encoding or streaming workloads exceeding Cloudflare Worker CPU limits (50ms free / 30s paid).
- Caching multi-gigabyte files (use Cloudflare R2 instead).
## Production Worker Implementation
```javascript
export default {
async fetch(request, env) {
const url = new URL(request.url);
// 1. CORS Preflight
if (request.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
}
});
}
// 2. Upstream Target Configuration
const UPSTREAM_TARGET = env.UPSTREAM_URL || "https://api.openai.com";
const targetUrl = new URL(ur