Errors and limits
An error is an error object; there is never a partial verdict.
{ "error": { "message": "Input exceeds the 4194304-byte limit for this key.", "type": "invalid_request_error", "code": "input_too_large" }}| Status | code |
When | What to do |
|---|---|---|---|
| 400 | invalid_request, invalid_json, invalid_utf8, invalid_query, empty_input, invalid_role, invalid_kind, unsupported_content, too_many_messages, model_not_found, invalid_body |
The request is wrong. | Fix the request; the message says what. |
| 401 | invalid_api_key |
The key is missing, unknown, expired or revoked. | Check the Authorization header and the key. |
| 403 | access_restricted |
The key is valid, but access is restricted for it or its organization. | Ask your organization’s administrator. |
| 408 | upload_timeout |
The body stalled or took too long to arrive. | Retry. |
| 413 | input_too_large, body_too_large |
Over the input limit, or a JSON body larger than its limit. | Send less, or, on /v1/scan, send it as text/plain. |
| 415 | unsupported_media_type |
The body is neither JSON nor, on /v1/scan, plain text. |
Set Content-Type. |
| 422 | input_unprocessable |
This input can never be scanned as sent. | Retrying will not help. |
| 429 | rate_limit_exceeded, scanner_busy |
The key’s rate limit, or the service is at capacity. | Wait for Retry-After seconds, then retry. |
| 503 | scanner_unavailable |
The service cannot scan for this key right now. | Retry with backoff. |
| 504 | scan_timeout |
The scan ran out of time. | Send less, or split the input. |
| 500 | scan_failed |
Anything else. No verdict was produced. | Retry with backoff. |
Nothing about a request is judged before its key: a request without a valid key gets 401, unless the service
itself is unavailable (503).
Rate limits and capacity
Section titled “Rate limits and capacity”A key can have a requests-per-minute limit, set when it is created. It is applied by each server of the
service, so a burst can slightly exceed it. When the service is busy, a request for a short input waits up to
about two seconds for capacity before it is refused with 429 scanner_busy; a large input waits for capacity
as it is scanned. Both 429 answers carry a Retry-After header in whole seconds: for
rate_limit_exceeded it is when the key has capacity again, for scanner_busy a short pause before retrying.
A one-line prompt is answered in tens of milliseconds; a megabyte takes tens of seconds. A response that is not streamed must arrive within about two minutes, or the connection is closed on the way: stream anything larger than the model’s context length. Closing the connection cancels the scan.