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
| Parameter | Env Variable | Default | Description |
|---|---|---|---|
access_key_id | TOUAI_ACCESS_KEY_ID | — | API key ID (ak_live_...) |
secret_key | TOUAI_SECRET_KEY | — | API secret key (sk_live_...) |
base_url | TOUAI_BASE_URL | https://platform.tou.ai | API base URL |
timeout | TOUAI_TIMEOUT | 60 | Request timeout in seconds |
max_retries | TOUAI_MAX_RETRIES | 3 | Max 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=5from 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()).