Keep your AI API key out of the browser.
A ready-to-deploy Cloudflare Worker that proxies Claude, DeepSeek and other
Anthropic-compatible LLMs for you.
Your key lives in a Worker secret. Your web app talks to your Worker. Nobody else.
Free download, MIT licensed, commercial use allowed.
No signup. No account. No telemetry. The ZIP contains everything you need.
The leak everyone hits
Put your API key in front-end JavaScript and anyone can open DevTools, copy it, and spend your money. A leaked Claude key can burn hundreds of dollars overnight.
The fix in one file
The Worker holds the key server-side, checks a shared secret, restricts origins, and rate-limits by IP. Your browser only ever sees your own endpoint.
You own everything
Your code, your Cloudflare bill, your logs. Swap models, enable streaming, tune limits. Nothing here talks to a third-party vendor.
What's in the ZIP
Seven files. Nothing else.
| File | What it does |
|---|---|
worker.js | The proxy itself: CORS allow-list, shared-secret auth, per-IP rate limiting, 20 KB request body cap, security headers. |
wrangler.toml | Deployment config — one command and you're live on Workers free or paid. |
DEPLOY.md | Step-by-step setup, tested on the Workers free plan. |
CUSTOMIZE.md | Switch providers, enable streaming responses, change rate limits. |
README.md | Quick start and configuration reference. |
CHANGELOG.md | Version history. |
LICENSE | MIT — use it commercially, modify it, ship it inside your own product. |
Deploy in about ten minutes
Cloudflare Workers free tier is enough to start.
- Unzip the kit, then install the Cloudflare CLI and log in:
npm install -g wrangler && npx wrangler login - Store your provider key as a Worker secret:
npx wrangler secret put LLM_API_KEY - Generate a random shared secret and store it too:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
thennpx wrangler secret put CLIENT_SECRET - Edit the config block at the top of
worker.js: put your domain inALLOWED_ORIGINS(this is the CORS allow-list), and setLLM_BASE_URL/DEFAULT_MODELfor your provider. - Deploy:
npx wrangler deploy— the output shows your Worker URL. - Confirm the deploy:
curl https://<your-worker>.workers.dev/health→{"status":"ok"} - Point your front end at
/v1/chatand send the shared secret in theX-Client-Secretheader.
POST https://<your-worker>.workers.dev/v1/chat
X-Client-Secret: <your CLIENT_SECRET>
{"messages":[{"role":"user","content":"hello"}]}
CLIENT_SECRET in front-end JavaScript either.
Put it behind a login, or have the browser call your own backend.
The Worker stops the API key leak; it can't stop you leaking the shared secret.
FAQ
Which providers does it support?
DeepSeek works out of the box — it is the default. Claude is a one-line change to LLM_BASE_URL and DEFAULT_MODEL. OpenAI / GPT also works, but it uses the Chat Completions shape, so callLLM() needs the small body-and-response tweak shown in CUSTOMIZE.md. Any other Anthropic-compatible endpoint works the same way.
Does it cost anything?
The Worker runs on Cloudflare's free tier for this kind of traffic. You pay your AI provider directly. There is no middleman and no subscription.
Can I use this in a commercial product?
Yes. MIT license permits commercial use, modification and redistribution. You are not required to credit anything, though a link back is welcome.
Why is it free?
Because it is a small, self-contained piece of engineering and most people need it once. If it saved you an afternoon, grab it and go.
What is the browser extension next to this?
PrivacyGuard is a Chrome extension that stops you pasting API keys and other secrets into AI chatbots. Different problem, same idea: keep the key on your side of the wire.