Test credit and test token

API errors and rate limits

How errors look, what each code means, how to respond, and how fast one key can go.

Failures arrive as ordinary JSON, and OpenAI SDKs map them to the classes you know (APIError, AuthenticationError, RateLimitError and so on).

{ "error": { "code": "spend_limit_reached", "message": "This API key reached its monthly spend limit", "monthlyLimitMicro": 5000000, "spentThisPeriodMicro": 5000000, "periodResetsAt": "2026-11-01T00:00:00.000Z" } }

Write your logic against error.code and leave the message text alone. Fields ending in Micro count micro-USD: $1 is 1,000,000.

Every code comes with a next move

HTTPCodeYour next move
400invalid_requestCorrect the field named in message
400upstream_rejectedThe model refused your input, for example because it overflows the context window
401invalid_api_keyBad or revoked key. Make a fresh one
402insufficient_creditsYour free and paid credits together fall short. Cut max_tokens, switch model or top up. resetsAt gives the free refill time
402spend_limit_reachedMonthly cap reached. Lift it on the Developers page or wait until periodResetsAt
403tee_api_not_availableTEE lives in the app. Send mode: "anonymous"
404model_not_foundNo such model id. Look it up with GET /v1/models
404model_unavailableNo answer possible at this moment, and no charge. Switch model or set fallback_models
404not_foundThat video job or media link is unknown or has expired
409request_in_progressAn image call with this X-Angerona-Request-Id hasn't finished. Poll GET /media/by-request/{id}
413payload_too_largeYour body exceeds 4 MB
422content_blockedThe safety check turned down this image or video prompt
429rate_limitedEase off and honor Retry-After
502upstream_errorProvider failure with no charge. Send it again
503upstream_unavailable, upstream_rate_limitedA passing problem with no charge. Back off and resend
503moderation_unavailableImage and video screening is offline. Try again in a moment
503media_unavailableStoring the image for delivery failed, with no charge. Send it again
500internal_errorA bug on our side. Resend, and let us know if it keeps happening

A key gets 120 requests per minute

  • All keys share this same per-key ceiling.
  • Cross it and you get 429 rate_limited, with Retry-After in seconds.
  • OpenAI SDKs resend 429 and 5xx by themselves, two times unless told otherwise.

Failed calls are free

  • Nothing is billed for a call that fails.
  • When a stream dies midway, only the prompt and the generated part are billed.
  • Resending carries no risk: each retry counts as its own request with its own bill.