Errors¶
A shallow hierarchy with structured fields (provider, phase, retryable,
http_status, detail, hint); detail is bounded and redacted, hint is the
actionable next step. The prose catalog with examples lives in
the error reference.
anyinfer.AnyInferError ¶
AnyInferError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: Exception
Base class for everything this library raises.
Attributes:
| Name | Type | Description |
|---|---|---|
detail |
Human-readable description, redacted and truncated to 512 characters. |
|
provider |
The provider id involved, when one is. |
|
phase |
Phase
|
Lifecycle stage that failed. |
retryable |
Whether retrying the identical request could plausibly succeed. |
|
retry_after_s |
Server-advised delay before retrying, when supplied. |
|
http_status |
Status code, for errors that came from an HTTP response. |
|
hint |
The actionable next step to show a user, when one exists. |
anyinfer.Phase
module-attribute
¶
Phase = Literal[
"configure",
"discover",
"generate",
"stream",
"validate",
"cleanup",
]
Which stage of the request lifecycle produced an error.
anyinfer.ConfigError ¶
ConfigError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "configure",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: _ConfigurePhaseError
Invalid configuration, target string, catalog entry, or missing optional extra.
anyinfer.CredentialError ¶
CredentialError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "configure",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: _ConfigurePhaseError
A credential reference could not be resolved.
anyinfer.AuthError ¶
AuthError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.ProviderError ¶
ProviderError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: AnyInferError
Base for anything a provider surfaced.
Adapters raise only these; they never retry internally. The router decides
what to do based on retryable and
retry_after_s.
anyinfer.ProviderUnavailableError ¶
ProviderUnavailableError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = True,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: _RetryableProviderError
The provider is down, unreachable, or failed its health probe.
anyinfer.RateLimitError ¶
RateLimitError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = True,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: _RetryableProviderError
The provider rate-limited the request.
anyinfer.ModelNotFoundError ¶
ModelNotFoundError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.ContextLengthError ¶
ContextLengthError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.TransportError ¶
TransportError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = True,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: _RetryableProviderError
Connect, timeout, or TLS failure — no usable response was received.
anyinfer.StreamProtocolError ¶
StreamProtocolError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "stream",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.SchemaViolationError ¶
SchemaViolationError(
detail: str,
*,
raw_text: str = "",
errors: tuple[str, ...] = (),
partial: Mapping[str, Any] | None = None,
missing_required: tuple[str, ...] = (),
provider: str | None = None,
phase: Phase = "validate",
hint: str | None = None,
)
Bases: AnyInferError
The response did not satisfy the requested schema, and the repair budget is spent.
Attributes:
| Name | Type | Description |
|---|---|---|
raw_text |
The model's raw output, so callers can inspect or salvage it. |
|
errors |
Human-readable validation error messages. |
|
partial |
Complete top-level members recovered without inference, or |
|
missing_required |
Required field names that were not completely received. |
anyinfer.UnsupportedInputError ¶
UnsupportedInputError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.SpendLimitError ¶
SpendLimitError(
message: str,
*,
limit_usd: Decimal | None = None,
spent_usd: Decimal | None = None,
estimated_usd: Decimal | None = None,
hint: str | None = None,
)
Bases: AnyInferError
A request was refused because it would cross a caller-set spending ceiling.
Raised before dispatch, so nothing was sent and nothing was billed. Deterministic by construction: the identical request refused once will be refused again, which is why the default retry predicate declines it alongside auth and context-length failures.
A ceiling is the caller's own policy on their own client; not an organization quota, which this library deliberately does not implement.
Attributes:
| Name | Type | Description |
|---|---|---|
limit_usd |
The ceiling that was crossed. |
|
spent_usd |
What this client had already spent when the request arrived. |
|
estimated_usd |
The high end of the refused request's estimated cost. |
anyinfer.ToolLoopError ¶
ToolLoopError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.AllTargetsFailedError ¶
AllTargetsFailedError(
detail: str = "all routing targets failed",
*,
attempts: tuple[AttemptRecord, ...] = (),
batch_failures: tuple[BatchFailure, ...] = (),
hint: str | None = None,
)
Bases: AnyInferError
Every target in the route failed.
Attributes:
| Name | Type | Description |
|---|---|---|
attempts |
The complete routing trail, in order, including skipped targets. |
|
batch_failures |
Per-internal-batch outcomes when the failed request had been split by core-owned batching — including the batches that succeeded, so a caller can see exactly what was spent before the failure. Empty for an unsplit request. |
anyinfer.LocalRuntimeError ¶
LocalRuntimeError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
anyinfer.ConfidentialExecutionError ¶
ConfidentialExecutionError(
detail: str,
*,
provider: str | None = None,
phase: Phase = "generate",
retryable: bool = False,
retry_after_s: float | None = None,
http_status: int | None = None,
hint: str | None = None,
)
Bases: LocalRuntimeError
ConfidentialExecutionAdapter refused to execute: the attestable guarantee a
caller requested is not available on this host right now.
Fails closed by design — this is never raised as a courtesy warning alongside a
completed generation; the generation never happened. See
anyinfer.local.attestation.confidential_execution_status for the detection this
check is built on.