Response shape
Every error returnsapplication/json carrying the same envelope:
code. It is a stable, all-caps name drawn from a closed set, and the codes each endpoint can return are listed below. message is a human-readable summary written for a person reading a log — it may be reworded at any time, so don’t match on it.
/chat/completions is the exception. It returns the OpenAI-shaped envelope (type, param, lower-case code) so that unmodified OpenAI SDKs work against it. See Chat Completions reference.When Errors caught before streaming starts — an invalid API key, an unrecognized
stream: true on /answer and a failure happens after streaming has already started, it’s delivered as a single terminal SSE frame under HTTP 200, with no trailing data: [DONE], rather than as a top-level error status. That frame carries the same code as the buffered response:scope, an oversized query — still return their normal status code and JSON body, whether or not stream is set.Status codes
413 and 429 are worth retrying only after changing the request or waiting. 503 is the one to retry unchanged.
The same envelope and the same codes are used by Fetch and Monitor, so one error handler covers every endpoint except /chat/completions.
Codes are per endpoint, and an endpoint may define one for a condition no other has —
/agent/runs answers a rejected output_schema with INVALID_OUTPUT_SCHEMA rather than a second flavour of INVALID_REQUEST. Treat an unrecognized code as a generic failure for its status class rather than rejecting the response.The 8 KiB limit on Answer
/answer’s query and system_prompt fields share an 8 KiB (8,192-byte) UTF-8 limit, since both are forwarded verbatim into the upstream prompt. Exceeding it returns a 400:
/answer. An oversized query on /search does not raise an error — it simply isn’t likely to match anything, and the response comes back as a normal 200 with an empty documents array.
Scopes
Both endpoints acceptscope: web (beta), news, wikipedia, people, companies, or financial-reports, defaulting to web when omitted. An unrecognized value returns 404 with code NOT_FOUND and the message Scope not found.
Next steps
- Search — Full request and response specification
- Answer — Full request and response specification
- Data Concepts — What each scope contains