Errors
Exceptions
Shared error types raised by both clients. Modus SDK exception hierarchy. All exceptions raised by the SDK are subclasses ofModusError. HTTP errors
are mapped from status codes; run errors are raised from stream events.
ModusError
Error
Base class for all Modus SDK errors.
HTTP failures map to subclasses by status code. Streaming run failures map
from event types (error, cancelled, stream_timeout).
Properties:
statusCode:numberrequestId:stringresponseHeaders:Record<string, string>body:stringcode:string
APIConnectionError
ModusError
Network-level failure (connection error, read timeout, 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 apiKey explicitly.
Create a token at app.getmodus.com → Settings → API Tokens.
PermissionDeniedError
ModusError
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).
Inspect errors when present for field-level details.
Properties:
errors:unknown
RateLimitError
ModusError
Too many requests (HTTP 429).
When present, retryAfter is the suggested wait in seconds.
Properties:
retryAfter:number
InternalServerError
ModusError
Unexpected server failure (HTTP 5xx).
RunCancelledError
ModusError
The run was cancelled before it finished.
StreamTimeoutError
ModusError
The streaming connection timed out before a final result arrived.
ValidationError
ModusError
Client-side argument validation failed before a request was sent
(for example an unsupported chat model id).