- HTTP errors: the API rejected the request or hit a server fault. Every endpoint returns the same envelope.
- Session failures: the request was accepted, but the run ended
failedortimed_out. The session’serror_codesays why.
Error object
Every error response carries the same envelope: amessage that summarizes the problem, and a detail array with one entry per problem. For 422 validation errors, each detail entry keeps the failing field’s path and reason, and message flattens them into one line:
Validation error (422)
401) may carry only a message.
HTTP status codes
Success codes
Client error codes
Server error codes
Handling errors with the SDK
The SDKs raise a typed error on any non-2xx response, withstatus_code / statusCode and the parsed body.
Over-quota session creates need no retry logic: they queue by default and start on their own.
Session failures
A settled session reports two signals onstatus, the Session object, and changes, so your code can branch without parsing prose.
Outcomes
A session can endcompleted and still not do what you asked. outcome is the agent’s own assessment, reported with its final answer:
outcome is a self-assessment, not verified ground truth: validate the answer itself for high-stakes flows. It is null when the agent ended without reporting one.
Error codes
When a session endsfailed or timed_out, it carries an error_code and an error message matching it:
error_codeisnullunless the status isfailedortimed_out.- New codes may appear: treat unknown values like
internal. erroris a stable template derived from the code, never raw internals. Branch onerror_code, logerror.