Configuration
All SDK settings can be provided either through constructor arguments or environment variables.
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://app.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://app.tou.ai",
timeout=120,
max_retries=5,
)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 automatically retries on 429, 500, 502, 503, and 504 responses with exponential backoff and respects Retry-After when present.