5abeer API error codes: meaning and fixes
Every error code the API can return, what it means and what to do next, plus the usage limits: a subscription's 5-hour and weekly limits.
On this page
When a request fails you get an HTTP status and an error code that names the cause. Look the code up here to see what to do next.
Error shape#
Errors come in two shapes. The key, balance and limit checks run before any model is called and answer with a flat body:
{ "code": "INVALID_API_KEY", "message": "Invalid API key" }Errors while serving the request follow the format of the endpoint you called and carry a request_id (also in the X-Request-ID header). Both shapes, with an example per format, are in Error shapes.
Error codes#
invalid_ request_ error400The request is incomplete or has an invalid value. Check the parameters and send it again.Check the requestINVALID_ REQUEST400The request couldn't be processed as sent. Check the fields and values, then send it again.Check the requestCONTEXT_ LIMIT_ EXCEEDED400The conversation is longer than the model's context window. Shorten it or start a new one.Check the requestAPI_ KEY_ REQUIRED401Send your API key with the request in the Authorization: Bearer or x-api-key header.Check the keyINVALID_ API_ KEY401That API key isn't valid. Copy it again from your dashboard.Check the keyINVALID_ AUTH_ HEADER401The header format is wrong. Use Authorization: Bearer <key>.Check the keyAPI_ KEY_ DISABLED401This key is disabled. Enable it in your dashboard or create a new one.Check the keyINSUFFICIENT_ BALANCE403Your balance isn't enough for this request. Top up, then try again.Top upAPI_ KEY_ EXPIRED403This key has expired. Extend its expiry date or create a new key.Check the keyMODEL_ PLATFORM_ NOT_ ALLOWED403This model isn't available for this key.Check the keyACCESS_ DENIED403Your IP address isn't allowed for this key. Add it to the key's IP allow-list.Check the keySUBSCRIPTION_ NOT_ FOUND403There's no active subscription for this key. Choose a plan or use a pay-as-you-go key.Choose a plannot_ found_ error404We couldn't find that model or path. Check the model id and the URL.Check the requestREQUEST_ TOO_ LARGE413The request is too large. Send fewer or smaller images and files.Check the requestRATE_ LIMITED429Too many requests in a short time. Slow down and try again.Wait, then retryINVALID_ AUTH_ RATE_ LIMITED429Too many attempts with an invalid key. Wait a little, then check the key.Wait, then retryAPI_ KEY_ QUOTA_ EXHAUSTED429This key reached the spend limit you set. Raise the limit in the key settings.Check the keyinsufficient_ quota429This key reached the spend limit you set. Raise the limit in the key settings.Check the keyUSAGE_ LIMIT_ EXCEEDED429You've reached your plan's usage limit. It renews automatically on schedule.Wait, then retryINTERNAL_ ERROR500Something went wrong on our side. Try again in a moment.Retryapi_ error500Something went wrong on our side. Try again in a moment.Retryupstream_ error502We couldn't reach the model provider just now. Try again in a moment.RetryMODEL_ UNAVAILABLE503The model is temporarily unavailable. Retry, or pick another model.RetrySERVICE_ UNAVAILABLE503A temporary problem on our side. Try again in a moment.RetryAUTHENTICATION_ FAILED503A temporary problem on our side, not your key. Try again in a moment.Retryoverloaded_ error503The model is busy right now. Try again in a moment or pick another model.RetryUPSTREAM_ TIMEOUT504The model took too long to answer. Retry; for long tasks use streaming.Retry27 codes
Usage limits#
Subscription limits#
A subscription has two usage limits only: a 5-hour limit and a weekly limit. When you reach one, you get USAGE_LIMIT_EXCEEDED with status 429, and the limit renews automatically on schedule. Your dashboard shows how much of each limit you have used and when it renews; details in Usage limits.
Pay-as-you-go keys#
The subscription limits don't apply to pay-as-you-go keys. What limits your requests there is your balance, and the spend limit if you set one on the key:
INSUFFICIENT_BALANCE: your balance doesn't cover the request. Top up, then try again.API_KEY_QUOTA_EXHAUSTED: the key reached the spend limit you set. Raise the limit in the key settings.RATE_LIMITED: too many requests in a short time. Wait a little, then try again.
When to retry#
429and5xxare temporary: retry with a wait that doubles each time, and cap the number of attempts.400,401and403won't go away on retry: fix the request, the key or the balance first.- A
429from a subscription limit doesn't clear with quick retries; the limit renews on schedule.
Still stuck?#
Contact us with the error code and the time of the request, and we'll look at it on our side. Never send your key in the message: we don't need it.
Was this page helpful?