Skip to main content

SDK Exceptions

This page lists Python SDK exception classes and what they usually mean.

For handling patterns and examples, see Python SDK: Error Handling.

Exception Reference

ExceptionUsually meansCommon status
AISDKErrorBase class for all SDK exceptions.Any
AuthenticationErrorAPI key is missing, invalid, expired, or unavailable to the process.401
NotFoundErrorAssistant, app, or another resource was not found or is not accessible.404
ValidationErrorRequest payload is invalid.422
ServerErrorAPI returned a server-side error.5xx
APIConnectionErrorSDK could not reach the API after retries.Network error
APIResponseErrorAPI returned another unclassified error response.Other 4xx

Error Fields

SDK errors may include:

FieldDescription
messageHuman-readable error message.
status_codeHTTP status code, when available.
endpointSDK endpoint path involved in the request.
payloadParsed response payload, when available.

Minimal Catch Pattern

from custodian_labs import AISDKError, create_assistant

try:
assistant = create_assistant(
model="gpt-4o",
prompt="You are a helpful assistant.",
)
except AISDKError as error:
print(error.status_code)
print(error.endpoint)
print(error.message)