- HTTP mapping: 401 -> AuthenticationError 403 -> PermissionDeniedError 404 -> NotFoundError 409 -> ConflictError 422 -> UnprocessableError 429 -> RateLimitError 5xx -> InternalServerError
- SSE event mapping: { type: “error” } -> ModusError (raised from run/stream) { type: “cancelled” } -> RunCancelledError { type: “stream_timeout” } -> StreamTimeoutError
ModusError
Exception
Base class for all Modus SDK errors.
APIConnectionError
ModusError
Network-level failure (ConnectError, ReadTimeout, etc.) after all automatic retries are exhausted.
AuthenticationError
ModusError
The API key is missing, invalid, or expired (HTTP 401).
Check that MODUS_API_KEY is set correctly, or pass api_key= explicitly. Create a token at app.getmodus.com → Settings → API Tokens.
PermissionDeniedError
ModusError
Raised when the API key does not have permission for the requested operation (HTTP 403).
NotFoundError
ModusError
The requested resource does not exist (HTTP 404).
ConflictError
ModusError
Idempotency conflict — a run with this ID already exists with a different body (HTTP 409). Use a new idempotency key or omit it to auto-generate.
UnprocessableError
ModusError
Request validation failed (HTTP 422). The errors attribute contains the full validation error detail.
RateLimitError
ModusError
Rate limit exceeded (HTTP 429).
The retry_after attribute contains the number of seconds to wait before retrying, if the server provided a Retry-After header. The SDK retries automatically — this error only surfaces after all retry attempts are exhausted.
InternalServerError
ModusError
The server encountered an internal error (HTTP 5xx). The SDK retries automatically — this error only surfaces after all retry attempts are exhausted.
RunCancelledError
ModusError
Raised when a chat stream is cancelled before completing.
StreamTimeoutError
ModusError
Raised when a chat stream times out before completion.