Exceptions#
- class saia_python.SAIAError(message: object, *, status_code: int | None = None, response_body: str | None = None)[source]#
Base exception for all SAIA API errors.
- Parameters:
message – Human-readable error message.
status_code – The upstream HTTP status, when the error came from a response (
Nonefor client-side errors).response_body – The raw upstream body, preserved so a caller can surface exactly what the server sent.
- class saia_python.AuthenticationError(message: object, *, status_code: int | None = None, response_body: str | None = None)[source]#
Raised on 401/403 responses — invalid or missing API key.
- class saia_python.RateLimitError(message: object, rate_limits: object = None, *, status_code: int | None = None, response_body: str | None = None)[source]#
Raised on 429 responses — rate limit exceeded.
Carries
rate_limits(the parsedRateLimitInfo) and, when raised byraise_for_status(), an informative message built byformat_rate_limit_error().
- class saia_python.APIError(message: object, status_code: int | None = None, response_body: str | None = None)[source]#
Raised on unexpected HTTP errors.
- class saia_python.StructuredOutputError(message: object, *, response: dict, finish_reason: str | None = None)[source]#
Raised when a chat response holds no answer that validates against the requested structured-output model.
The HTTP call itself succeeded, so
status_codeisNone; the message says why the answer is unusable. The response stays attached, so a caller can still readusage(the tokens were spent) or inspect the raw content.- Variables:
response – The chat response dict the answer was read from.
finish_reason – The first choice’s
finish_reason—"length"means the token budget ran out — orNonewhen there was no choice.