Skip to content
Intura

Reference

Configuration

The client's arguments and environment variables: download key, cache folder, API root, timeouts, retries, your own httpx client and logging.

Settings and where they come from

SettingArgumentEnvironment
Download keyIntura(api_key=...)INTURA_API_KEY
Cache folderload(..., cache_dir=...)INTURA_CACHE_DIR, then XDG_CACHE_HOME
API rootIntura(base_url=...)INTURA_BASE_URL (default https://ai.intura.co/api)

An argument wins over the environment. With no cache folder set, models go in ~/.cache/intura.

The client's arguments

python
Intura(
    api_key=None,          # your download key; falls back to INTURA_API_KEY
    *,
    base_url=None,         # falls back to INTURA_BASE_URL, then https://ai.intura.co/api
    timeout=None,          # seconds to wait for one API response; 30 by default
    max_retries=2,         # retries for connection errors, timeouts, 429 and 5xx
    default_headers=None,  # sent on every API request
    http_client=None,      # your own httpx.Client
)

AsyncIntura takes the same arguments, with an httpx.AsyncClient for http_client.

  • api_key is needed only by the calls that reach the API, so loading a cached model works without one. See Download keys.
  • timeout applies to each API call. Left unset with an http_client of your own, that client's timeout is used rather than overwritten.
  • max_retries counts retries for a call the service never answered, rate limited or failed on. A request rejected for its content is never retried. See Errors.
  • default_headers are for a proxy or a trace header, not for auth.

Bring your own httpx client

For a proxy or a custom transport, bring your own httpx client. The package sets the URL and headers on each request, and never closes a client it did not open:

python
import httpx
from intura_ai import Intura

client = Intura(http_client=httpx.Client(proxy="http://proxy:3128"))

Closing the client

A client opens a connection pool for its API calls. Use it as a context manager, or call close() (await aclose() on AsyncIntura) when you are done:

python
with Intura() as client:
    model = client.models.load("chat-commerce-intent-id")

model.predict("ongkirnya berapa?")   # the model doesn't need the client

Logging

The package logs through the standard logging module, under the intura_ai logger, and is silent until your application attaches a handler. For a script or a notebook, set_verbose() prints its lines to stderr, including a line when a model starts downloading:

python
import intura_ai

intura_ai.set_verbose()          # INFO and above
intura_ai.set_verbose(False)     # back to warnings only

The installed version

python
import intura_ai

intura_ai.__version__

or intura-ai --version in a shell.