Every error the API returns: the HTTP code, the type field, what it means and what to try first.
{"type": "error", "error": {"type": "rate_limit_error", "message": "…"}}{"error": {"type": "rate_limit_error", "message": "…"}}Errors come back in the format of the API you called. An error before generation starts costs nothing; you pay only for tokens actually generated.
The request has no API key, the key is mistyped, or it has been revoked.
The balance is used up, or it does not cover the largest possible cost of this request. The cost is estimated from the input and max_tokens before the request starts. Context the previous request already cached (same model, within the cache window) is estimated at the cache-read rate. A refused request appears in History with a charge of 0.
This key already has the maximum number of requests in progress. The response carries Retry-After: 1.
This is not an outage and not a mistake on your side. The balance left is already reserved for your other requests that are still running, so this one waited up to 20 seconds for them to finish. The message starts with “Low balance:” (on the free plan: “Free plan limit:”) and shows the balance left and how many requests are running. A refused request appears in History with a charge of 0.
This is not an error. The key runs on free starter tokens, and free plan limits apply: requests per minute, requests at a time, available models, no images or video, and the free tokens themselves. The message starts with “Free plan limit:” and says what was reached. A refused request appears in History with a charge of 0.
The service is under heavy load right now and could not take this request. You are not charged.
The body is not a JSON object, or a parameter is wrong or not accepted for this model. The message field says what exactly.
This request uses a feature that is not available for your key — usually tools (tool_use), attachments or count_tokens.
The path does not exist, or the model id is not available.
The body is larger than 64 MB, or it is too large for the model. Large images and long chat history are the usual cause.
A streaming answer started, but it was cut off before the final event. History records it as 500. Only the tokens generated before the break are charged.
/v1/images/generations is not served through the API.
Something went wrong on our side. A request that fails this way costs nothing.