Developer API
Errors and Billing
Most long-running jobs return queued ids immediately. Billing and budget responses include credit fields so clients can show clear user-facing decisions.
#HTTP errors
Clients should branch on status code and error code, then show user-facing billing or retry decisions.
401Missing, expired, or invalid bearer token.
402Insufficient credits, budget exceeded, or premium approval required.
403The API key is valid but does not include the scope required for the endpoint.
404Requested generation, repurpose task, user, or account was not found.
409The device code has already been used or the request conflicts with current state.
429The API key or organization exceeded the current request limit.
502The gateway could not reach or read an upstream provider.
503No configured provider route is available or the upstream provider failed.
500Queue, database, provider, or internal processing failure.
#Error response shapes
Most endpoints return a structured error body with code and message. AI Gateway chat routes return OpenAI-compatible error.type, error.code, and error.message. Some legacy media handlers still return a string error body.
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits"
}
}
{
"error": {
"type": "provider_unavailable",
"code": "provider_unavailable",
"message": "No configured provider route completed the request"
}
}