Skip to main content
When something fails, start with the exception class. If you need a symptom-based guide, use Troubleshooting. All Tex exceptions inherit from tex.TexError. Most apps catch one of these: TexHTTPError (alias of APIStatusError) and TexAuthError (alias of AuthenticationError) are kept for backward compatibility.

Common fields

APITimeoutError and APIConnectionError are network errors, not HTTP errors. They do not have status_code, request_id, details, or response_text because the request never produced a response. Catch them separately.

Per-class details

BadRequestError

Raised when a payload is malformed. Common causes:
  • Missing required field on a turn (e.g. no text)
  • Invalid mode value on recall
  • Invalid session_id value. It must be a string.
e.details includes a Pydantic-style loc list that points to the bad field.

AuthenticationError

Status 401. The SDK already tried one JWT refresh before raising.

PermissionDeniedError

Status 403. The credential is valid but lacks scope. This mostly matters for scoped keys. Default keys should not hit this.

NotFoundError

Status 404. You referenced something that does not exist. This is often a stale key_id on DELETE /me/api-keys/{id}.

UnprocessableEntityError

Status 422. FastAPI validation rejected the payload. The SDK builds payloads for you, so this usually means an argument has the wrong type.

RateLimitError

Status 429. The SDK retries on 429 like other transient codes (with exponential backoff and Retry-After honored), so by the time you see this exception the SDK has already exhausted retries. For daily-quota 429s, retries will not help until midnight UTC. Set max_retries=0 on paths where you would rather fail fast:
The e.details payload tells you which cap was exceeded (tokens_in_daily or tokens_out_daily) and when it resets:

InternalServerError

Status 5xx. The SDK already tried the request again with exponential backoff. If you still see this, file a ticket with e.request_id.

APITimeoutError

The request did not return within timeout. The SDK retries timeouts. If every attempt fails, it raises APITimeoutError.

APIConnectionError

DNS, TLS, or socket-level failure. The retry behavior is the same as APITimeoutError. If you see this in production, check your egress proxy or firewall.

Built-in retries

The SDK retries automatically on:
  • Status codes: 408, 429, 500, 502, 503, 504
  • httpx.TimeoutException
  • httpx.HTTPError (network)
Default: 2 retries with exponential backoff (0.5s, 1s). Override:
The SDK honors Retry-After. If the server says wait 3 seconds, the SDK waits at least 3 seconds.
Quota 429s retry like other 429s. The retry will still fail if you are over the cap. Set max_retries=0 on quota-sensitive paths if you want to fail faster.

Idempotency

remember is idempotent because Tex deduplicates turns by hash. recall and usage.* are read-only. It is safe to retry any of them.

Next: REST API

Direct HTTP integration without the SDK.