The hierarchy is deliberately shallow (~10 classes) with rich structured fields, because
callers branch on fields far more often than on exception class:
exceptai.AnyInferErroraserror:error.detail# what happened — redacted, ≤512 charserror.hint# the actionable next step, when one existserror.provider# which provider, when applicableerror.phase# configure | discover | generate | stream | validate | cleanuperror.retryable# would repeating this identical request help?error.retry_after_s# server-advised delay, when suppliederror.http_status# status code, for HTTP-sourced failures
detail and hint always pass redaction, so no error can leak a credential no matter where
it is logged.
AnyInferError
├── ConfigError bad config, target, catalog, or a missing extra
├── CredentialError a credential reference could not be resolved
├── ProviderError base for anything a provider surfaced
│ ├── AuthError
│ ├── RateLimitError
│ ├── ModelNotFoundError
│ ├── ContextLengthError
│ ├── TransportError
│ ├── StreamProtocolError
│ └── ProviderUnavailableError
├── SchemaViolationError validation failed after the repair budget
├── ToolLoopError unknown tool, bad signature, or round bound exceeded
├── AllTargetsFailedError the router exhausted every target
└── LocalRuntimeError llama-server lifecycle, or model integrity
ProviderError is a distinct branch on purpose: it is exactly what the router catches and
may retry. ConfigError, SchemaViolationError, and AllTargetsFailedError are not
provider errors and propagate straight to you.
When: an unknown target or provider, a malformed catalog, a missing required setting, or
a provider whose optional extra is not installed.
Retryable: no.
ConfigError: unknown target 'gpt-5'
(hint: use 'provider:model' (e.g. 'anthropic:claude-sonnet-5'), or one of these
aliases: large, medium, small)
ConfigError: the copilot provider requires the github-copilot-sdk extra
(hint: pip install 'anyinfer[copilot]', then run 'copilot login')
How to fix
Read error.hint — it names the exact target spelling, alias, or install command to
use next.
When: malformed SSE/NDJSON framing, or a response exceeding max_response_bytes.
Retryable: no by default. Note that if content had already been emitted, this is
raised rather than retried — the consumer has seen text, and silently restarting would
duplicate or contradict it.
When: llama-server failed to start, crashed, timed out becoming ready, could not be
reaped, or a model artifact failed hash verification.
LocalRuntimeError: llama-server exited with code 3 while loading qwen2.5-7b:
fatal: unable to load model
(hint: the model may be incompatible with this runtime build, or the machine may
have run out of memory)
The server's own log tail is included, because polling a health endpoint alone tells you
nothing about why it failed.
How to fix
Read the included log tail first — it usually names the real cause (OOM, an
incompatible GGUF, a port conflict). See the local subsystem.