Skip to content

Rate Limits

CodeGate does not currently enforce a per-key rate limit at the gateway. The effective ceiling on your traffic is:

  1. The upstream provider's rate limit for the model you targeted.
  2. Your prepaid credit balance.

Upstream limits

Every request is forwarded to a real upstream provider (Anthropic or OpenAI). Those providers have their own per-tenant limits, and if you exceed them, they return 429 Too Many Requests. CodeGate passes that response back to you.

The exact upstream limits vary by provider, model, and internal capacity. In practice, individual users rarely hit them, because CodeGate rotates traffic across a pool of upstream tenants.

Prepaid balance

When your balance runs out, requests return 402 Payment Required. Add credit at Console, Top Up and requests resume immediately.

You can bound risk per key by setting a spend quota at Console, API Keys. A key with a $10 quota can never spend more than $10 no matter what, even if your account balance is larger.

Handling 429

When you see a 429, back off and retry. A minimal shell retry loop:

bash
attempt=0
until curl -sS -f -o /tmp/resp.json -w "%{http_code}" https://codegate.dev/v1/chat/completions \
    -H "Authorization: Bearer sk-..." \
    -H "Content-Type: application/json" \
    -d '{"model":"gpt-5.5","messages":[{"role":"user","content":"Hi"}]}' \
    | grep -q '200'; do
  attempt=$((attempt + 1))
  if [ "$attempt" -ge 4 ]; then
    echo "gave up after $attempt attempts"
    break
  fi
  sleep $((2 ** attempt))
done

Most SDKs (OpenAI's, Anthropic's) do this automatically. If you are writing one from scratch, follow the same pattern.

Persistent 429s

If you are hitting 429 repeatedly, it usually means an upstream tenant is throttling. Options:

  • Wait a few seconds and retry. CodeGate re-routes across upstreams on retry so a second attempt often lands on a healthy one.
  • Reduce your request rate or batch size.
  • If it is a real capacity problem for your workload, join the Discord and we will look at your account and see what we can raise upstream.

Notes

  • Streaming does not count against a separate stream cap. What matters is the token throughput, not the connection count.
  • A 429 from upstream is transient. A 5xx is a transient upstream failure and is usually resolved by one retry.
  • A 402 is not a rate limit; it means you have to add credit.

Next

Built on new-api. Served by CodeGate.