Skip to main content
Errors can happen before a response starts or after a streaming response is already in progress. Your client should handle both cases.

Standard error shape

All APIs use normal HTTP status codes for non-streaming failures, with error payloads that include a machine-readable type and a human-readable message. Typical JSON error:

Common status codes

Streaming Errors

Streaming APIs can fail after the server has already sent 200 OK. In that case, the error arrives inside the stream instead of as a normal JSON body.
A streamed 200 OK only means the connection started successfully. It does not guarantee the model finished successfully. Keep parsing the stream until you see the real terminal event or error frame.
Clients should parse frames structurally instead of blindly appending text. Example mid-stream error payload:

Retry guidance

  • do not blindly retry 400 or 401
  • retry 429, 500, and 503 with exponential backoff
  • keep retries bounded and log the final failure

Practical advice

  • always branch on the machine-readable error.type
  • log unknown error payloads before normalizing them away
  • stop normal stream processing as soon as an error frame appears
  • keep HTTP-level errors and late-stream errors in the same client error model when possible