ModelHubby

← All guides · provider record →

Cloudflare Workers AI — free tier setup

What you get free

A permanent free allocation on Cloudflare's edge inference, metered in "Neurons" rather than requests or tokens. Per the catalog: "Our free allocation allows anyone to use a total of 10,000 Neurons per day at no charge." and "Neurons are our way of measuring AI outputs across different models, representing the GPU compute needed to perform your request." The gotcha: every request needs two credentials — an API token in the header and your account ID embedded in the URL path — and all 50+ free models drain the same single 10,000-neuron daily pool.

Friction check

Credit card no
Phone verification no
Org/membership none (any Cloudflare account)
Est. time to first key ~15m (5 steps)
Trains on your prompts unknown

Get a key

You need two values: an API token and your account ID.

  1. Sign up / log in at dash.cloudflare.com.
  2. Navigate to the Workers AI page: https://dash.cloudflare.com/?to=/:account/ai/workers-ai.
  3. Select "Use REST API".
  4. Choose "Create a Workers AI API Token", review the prefilled info, select "Create API Token", then "Copy API Token" and save it. (If you build a custom token instead, it needs both "Workers AI - Read" and "Workers AI - Edit" permissions.)
  5. On the same page, copy the value listed for "Account ID" — you will put it in the request URL.

First request

Both the token (header) and account ID (URL path) are required. Catalog OpenAI-compatible base URL: https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1. Expected success shape: a JSON chat.completion object with choices[0].message.content.

export CLOUDFLARE_API_TOKEN="YOUR_KEY"
export CLOUDFLARE_ACCOUNT_ID="YOUR_ACCOUNT_ID"   # from step 5 — goes in the URL, not a header
curl "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/v1/chat/completions" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
    "messages": [{"role": "user", "content": "ping"}],
    "max_tokens": 16
  }'

(Native endpoint also exists: .../accounts/{account_id}/ai/run/@cf/<model> with a {"prompt": "..."} body, response in a "response" field. Model ids are prefixed @cf/. Also callable from Workers via the env.AI binding.)

Limits that will bite you

  • One shared pool: 10,000 Neurons/day across all models — there are no per-model RPM/RPD/TPM caps in the catalog (shared_pool: true); a heavy model burns the pool fast.
  • Neurons measure GPU compute per request, so cost-per-request varies by model — probe to learn each model's real neuron burn before routing bulk traffic.
  • Resets daily at 00:00 UTC.
  • Past the free allocation you need a paid Workers plan ($0.011 per 1,000 Neurons) — requests don't silently continue free.
  • Streaming and tool-calling support: unknown in the catalog — verify per model.

Key rotation runbook

  • Second key: create another API token via the same "Use REST API" flow (or My Profile → API Tokens with Workers AI Read + Edit permissions). Note: the neuron pool is per account, so a second token does not add quota — only a second account does.
  • Revoke: delete or roll the token from the dashboard's API Tokens page.
  • ModelHubby integration: export CLOUDFLARE_API_TOKEN_2="..." — the key pool picks it up automatically; state machine cools down rate-limited keys per-key. (A second token on the same account shares the account ID; a second account needs its own account ID in the URL.)

ModelHubby usage

pnpm mh show cloudflare-workers-ai
pnpm mh probe --live --provider cloudflare-workers-ai --apply