Error envelope
Most error responses use this OpenAI-compatible JSON shape:type is a broad category, code is a specific identifier. Some
fast-path failures (notably workspace-level 429s) return only an HTTP
status code with the relevant headers and no JSON body.
HTTP status codes
Error types you may see in error.type
Error codes you may see in error.code
These are gateway-issued codes for failures that originate in
ClearMaas (not the upstream):
If you need to programmatically distinguish, match on
error.code
first (specific) and fall back to error.type (broad category).
Streaming errors
Errors during a streamed response can’t use HTTP status codes (the status was sent when the stream opened). The format depends on the endpoint:/v1/chat/completions and /v1/responses (OpenAI-compatible)
The error arrives as an in-band data: {...} chunk:
data: chunk as JSON; if it has an error field, treat
the stream as failed.
/v1/messages (Anthropic-compatible)
Anthropic uses SSE named events. A stream failure arrives as:
event: message_stop (or is cut) after
the error event.
Fallback errors
Whenextra_body.models is set and all models in the chain fail, you
get a 502 with details about the last upstream error. Response
headers X-Clear-Fallback-Level and X-Clear-Fallback-Model indicate
which fallback was being tried when the chain exhausted. See
Response Headers.