Skip to content

errors

Structured API error response contract.

The API server emits this shape for all handled application errors. detail is the human-readable message; code is the stable machine-readable discriminator clients should branch on; context carries optional error-specific structured fields (e.g. for usage-limit errors: the resource, variant, limit, and current usage).

ErrorResponse pydantic-model

Bases: BaseModel

Structured error body returned by the API for handled errors.

Fields:

code pydantic-field

Stable machine-readable error code; branch on this, not on the detail text.

context = None pydantic-field

Optional error-specific structured fields. Values may be scalars (e.g. usage_limit_exceeded: resource, limit, current) or nested JSON (e.g. consent_required: pending = [{document, current_version}, ...]). Backward-compatible: scalar contexts are unchanged.

detail pydantic-field

Human-readable description of the error.