/v1/messages, OpenAI-shape on
/v1/chat/completions + /v1/responses + /v1/tasks/* + /v1/images/*,
Google-shape on /v1beta/....
Failures never bill. This is a hard contract — X-Quota-Remaining-Credits
doesn’t move on a non-2xx, no entry appears in /api/v1/me/usage,
no row in /api/v1/me/billing/transactions.
Envelope shapes
- Anthropic
- OpenAI
- Google (Gemini Native)
error.type values: invalid_request_error, authentication_error,
permission_error, not_found_error, request_too_large,
rate_limit_error, api_error, overloaded_error.Status code matrix
400 Bad Request
Bad input. Never retry — the request will fail again with the same body.401 Unauthorized
Auth problem. Never retry — fix the credentials first.402 Payment Required
You ran out of money or hit a quota. Conditional retry — only after topping up or raising the cap.403 Forbidden
Authorized but not allowed. Never retry — adjust the key, group, or IP.404 Not Found
Endpoint or resource doesn’t exist. Never retry.413 Request Entity Too Large
Body exceeded the route’s cap. Never retry with the same body.429 Too Many Requests
Rate limit. Retry — useX-RateLimit-Reset to pick the backoff.
See Rate limits for the backoff strategy.
500 Internal Server Error
Gateway-side fault. Retry with exponential backoff (1s, 2s, 4s, 8s, give up at 4 attempts).502 / 503 / 504 — Service errors
The request couldn’t be completed server-side. Retry with backoff; ByteSpike already retried internally before surfacing.
For 503 specifically, click Test next to the model in
Console → Models — it
runs a dial-test that confirms whether the key + group + model
combination is actually viable.
Retry decision matrix
Idempotency on retries
The text endpoints (/v1/messages, /chat/completions, /responses)
are not idempotent — retrying after a 200 will run the model twice.
Don’t retry unless you got an error.
The tasks API is idempotent via out_task_id. Send the same
out_task_id on retry and the dispatcher returns the existing
task instead of starting a new one.
Anthropic-specific: error event in SSE
When a stream fails mid-flight, you’ll see a terminal
event: error instead of event: message_stop:
OpenAI-specific: error field in final frame
Reading errors programmatically
Related
- Rate limits — full 429 handling
- Authentication — what 401/403 means and how to fix
- Credits & billing — 402 + the no-charge guarantee
- Async tasks — mid-task errors via
/tasks/query