Skip to main content
Every error the LangWatch AI Gateway writes itself uses one JSON envelope:
The OpenAI, Anthropic and Google SDKs parse this shape and raise their usual typed exceptions.

Fields

Ignore fields you do not recognize. New ones are added over time and none of them changes an existing one.

Error codes

Provider errors

A provider’s own terminal response is forwarded instead of being replaced. The status is the provider’s, and the body is the provider’s own bytes when the adapter captured them. Retry-After and x-should-retry are forwarded with it, so a client can honor the provider’s backoff hint. When only the status and the message are available, the gateway writes the same envelope with the provider’s error discriminant in type and code, for example insufficient_quota or overloaded_error, and provider_error when the adapter parsed neither.

Response headers

X-LangWatch-Budget-Warning is set on successful responses. A budget in warning never becomes an error envelope.
A non-streaming call that runs long writes a keep-alive byte, which commits status 200 before the outcome is known. The response then carries X-LangWatch-Heartbeat-Active: true, and the body still holds an error key when the call failed. Read the body rather than the status on those responses.

Streaming errors

Once the stream is open the status is already 200, so a failure arrives as a terminal event: error frame and the stream ends:
error.type is the gateway code from the table above, or the provider’s own error discriminant on a forwarded failure. When the provider sent a native error body, that body is written into the frame verbatim instead. Treat a stream that delivered chunks and then an error frame as incomplete.
Last modified on September 6, 2026