Overview
TeenageWorks SDK
Quickstart
Configuration

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:

  1. A value passed to the client.
  2. A TEENAGEWORKS_ environment variable.
  3. Its matching TW_ alias.

Python

from teenageworks import TeenageWorks

client = TeenageWorks(api_key="tw_live_...")

Client options

OptionEnvironment variableAliasDefault
api_keyTEENAGEWORKS_API_KEYTW_API_KEYRequired
base_urlTEENAGEWORKS_BASE_URLTW_BASE_URLhttps://api.teenage.works/v1
timeoutTEENAGEWORKS_TIMEOUTTW_TIMEOUT600 seconds
max_retriesTEENAGEWORKS_MAX_RETRIESTW_MAX_RETRIES2

Python

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.

Python

slower_client = client.with_options(timeout=90.0, max_retries=4)
Note

Provider patches use the TeenageWorks key for rerouted speech. Calls that pass through keep the provider's own credentials and endpoint.