Configuration
The quickstart uses environment variables. You can also pass the same values directly when creating a client.
API key
Configuration is resolved in this order:
- A value passed to the client.
- A
TEENAGEWORKS_environment variable. - Its matching
TW_alias.
from teenageworks import TeenageWorks
client = TeenageWorks(api_key="tw_live_...")Client options
| Option | Environment variable | Alias | Default |
|---|---|---|---|
api_key | TEENAGEWORKS_API_KEY | TW_API_KEY | Required |
base_url | TEENAGEWORKS_BASE_URL | TW_BASE_URL | https://api.teenage.works/v1 |
timeout | TEENAGEWORKS_TIMEOUT | TW_TIMEOUT | 600 seconds |
max_retries | TEENAGEWORKS_MAX_RETRIES | TW_MAX_RETRIES | 2 |
client = TeenageWorks(
timeout=30.0,
max_retries=2,
)Remote base URLs must use HTTPS. Loopback HTTP is allowed for local testing.
Derive a client
Use with_options() when one request flow needs different settings.
slower_client = client.with_options(timeout=90.0, max_retries=4)