Configuration

All SDK settings can be provided either through constructor arguments or environment variables. Authentication is always a project API key — there are no other auth-related settings.

Configuration Matrix

ParameterEnv VariableDefaultDescription
access_key_idTOUAI_ACCESS_KEY_IDAPI key ID (ak_live_...)
secret_keyTOUAI_SECRET_KEYAPI secret key (sk_live_...)
base_urlTOUAI_BASE_URLhttps://platform.tou.aiAPI base URL
timeoutTOUAI_TIMEOUT60Request timeout in seconds
max_retriesTOUAI_MAX_RETRIES3Max retry attempts for 429 and 5xx responses

Constructor Example

from touai import TouAI
 
client = TouAI(
    access_key_id="ak_live_...",
    secret_key="sk_live_...",
    base_url="https://platform.tou.ai",
    timeout=120,
    max_retries=5,
)

The same keyword arguments work on AsyncTouAI.

Environment-Driven Setup

export TOUAI_ACCESS_KEY_ID=ak_live_...
export TOUAI_SECRET_KEY=sk_live_...
export TOUAI_TIMEOUT=120
export TOUAI_MAX_RETRIES=5
from touai import TouAI
 
client = TouAI()

Use constructor arguments for per-process overrides. Use environment variables when you want consistent configuration across scripts, local shells, and CI jobs.

Retry Behavior

The SDK retries with exponential backoff and respects Retry-After when present. 429 responses are retried for every request. 500, 502, 503, and 504 responses are retried only when replaying the request cannot double-execute or double-bill: GET requests, or writes that carry an Idempotency-Key (e.g. connectors.connections.query()).

AuthenticationClient Lifecycle