API
Errors
Errors use the OpenAI shape: an error object with a human-readable message, a type and a stable code. Match on code, not on the message text.
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"error": {
"message": "insufficient balance: 0.000000 USD available, this request may cost up to 0.001000 USD. Lower max_tokens or top up.",
"type": "insufficient_quota",
"code": "insufficient_balance"
}
}Status codes
| Status | Code | What to do |
|---|---|---|
400 | bad_request, model_not_found | Fix the request body or the model id; check /v1/models. |
401 | invalid_api_key | The key is wrong or revoked. Create a new one in the dashboard. |
402 | insufficient_balance | Top up, or lower max_tokens so the worst case fits your balance. |
402 | x402 challenge | No key was sent: either add your key or pay the request with x402. |
5xx | upstream_error, service_unavailable | Temporary. Retry with exponential backoff. |
Retries
- Retry
5xxresponses with backoff — for example 1 s, 2 s, 4 s. - Do not retry
400,401or402: the same request will fail the same way.