Skip to content
Intura

Reference

Errors

Every exception intura_ai raises, when each one happens, and what to do about it. A loaded model's predict raises none of them.

One base class

Everything this package raises descends from InturaError, so you can catch one class:

python
from intura_ai import Intura, InturaError

try:
    model = Intura().models.load("chat-commerce-intent-id")
except InturaError as exc:
    print(f"Could not get the model: {exc}")

Only the API calls and the download raise these. Once a model is loaded, predict raises nothing from this list, because it runs in your process.

The ones you will meet

ExceptionWhen
MissingAPIKeyA download was needed and no key is set
AuthenticationErrorThe key is wrong or revoked
NotFoundA model you don't own, or a version that doesn't exist
RateLimitedToo many calls in a short time. Retried for you first, and retry_after says when to try again
TransferErrorCloud Storage refused or dropped a file. Nothing was cached, so it's safe to retry
APIConnectionError / APITimeoutErrorThe API could not be reached. A model already in the cache still loads

Each message says what to do, not only what went wrong. MissingAPIKey, for example, shows both ways to set a key and links to your account page.

The rest of the family

Every error the API answered with a status code is an APIError. It carries status_code, message (the text the service wrote) and request_id, the string to quote when you ask for help.

ExceptionStatusWhen
InvalidRequest400The request could not be read
AuthenticationError401No key, an unknown key, or a revoked one
PermissionDenied403A valid key that may not do this
NotFound404A model you don't own, a version that doesn't exist, or a base_url with a path already on it
InvalidParameters422A value is wrong; the message names the field
RateLimited429Too many calls too quickly
ServerError5xxThe service failed. Retried automatically before you see it

APIConnectionError (and its subclass APITimeoutError) and TransferError are not APIErrors: the service never answered, or the file came from Cloud Storage rather than from Intura. TransferError has a status_code too, which is the bucket's.

Retries

The client retries connection errors, timeouts and 408, 429, 500, 502, 503 and 504 responses for you, up to max_retries times (2 by default), waiting between attempts (as long as the service's Retry-After asks, when it sends one). Seeing RateLimited or ServerError means those retries ran out. A request the service rejected for its content is never retried. See Configuration to change the count.

Errors outside the family

ExceptionWhen
FileNotFoundErrorLocalModel.load(path) was given a folder that isn't a downloaded model
ValueErrorload was given both version= and refresh=True, or a slug or version that isn't one
TypeErrorpredict was given something other than a str, or predict_batch a single str

Work offline when the API is down

A model already in the cache loads without the API. If asking for the newest version fails, fall back to the newest one you already have:

python
from intura_ai import APIConnectionError, Intura

client = Intura()
try:
    model = client.models.load("chat-commerce-intent-id", refresh=True)
except APIConnectionError:
    model = client.models.load("chat-commerce-intent-id")   # the newest cached version