Exception Handling
AnyLLMError
Bases: Exception
Base exception for all any-llm errors.
All custom exceptions in any-llm inherit from this class. It preserves the original exception for debugging while providing a unified interface.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Human-readable error message |
|
original_exception |
The original SDK exception that triggered this error |
|
provider_name |
Name of the provider that raised the error (if available) |
Source code in src/any_llm/exceptions.py
AuthenticationError
Bases: AnyLLMError
Raised when authentication with the provider fails.
Source code in src/any_llm/exceptions.py
ContentFilterError
Bases: AnyLLMError
Raised when content is blocked by the provider's safety filter.
Source code in src/any_llm/exceptions.py
ContextLengthExceededError
Bases: AnyLLMError
Raised when the input exceeds the model's maximum context length.
Source code in src/any_llm/exceptions.py
InvalidRequestError
Bases: AnyLLMError
Raised when the request to the provider is invalid.
Source code in src/any_llm/exceptions.py
MissingApiKeyError
Bases: AnyLLMError
Raised when a required API key is not provided.
Source code in src/any_llm/exceptions.py
ModelNotFoundError
Bases: AnyLLMError
Raised when the requested model is not found or not available.
Source code in src/any_llm/exceptions.py
ProviderError
Bases: AnyLLMError
Raised when the provider encounters an internal error.
Source code in src/any_llm/exceptions.py
RateLimitError
Bases: AnyLLMError
Raised when the API rate limit is exceeded.
Source code in src/any_llm/exceptions.py
UnsupportedParameterError
Bases: AnyLLMError
Raised when a parameter is not supported by the provider.
Source code in src/any_llm/exceptions.py
UnsupportedProviderError
Bases: AnyLLMError
Raised when an unsupported provider is specified.