SDK
Text to speech
Provider patches
OpenAI patch
ElevenLabs patch
Patch parameters
Migration and troubleshooting

Provider patches

Use a patch only when an application already calls OpenAI or ElevenLabs for text to speech. New applications should use the native SDK.

1. Install the provider extra

OpenAI

Linux / Mac / Windows

python -m pip install "teenageworks[openai]"

ElevenLabs

Linux / Mac / Windows

python -m pip install "teenageworks[elevenlabs]"

2. Configure credentials

Set TEENAGEWORKS_API_KEY for rerouted speech. Keep the original provider key configured for calls that pass through.

3. Apply the patch during startup

Python

from teenageworks import patch_elevenlabs, patch_openai

openai_patch = patch_openai()
elevenlabs_patch = patch_elevenlabs()

Apply only the patch or patches used by your application. Importing teenageworks alone changes nothing.

4. Keep using the provider client

Recognized TTS calls now route through Teen V1. Unknown TTS models and every non-TTS resource continue to the original provider.

Provider callRouted to TeenageWorks when
OpenAI audio.speech.create()The model is a recognized TTS ID
ElevenLabs text-to-speechThe model is teen-v1, starts with eleven_, or uses the provider default

Remove a patch

Python

assert openai_patch.is_active
openai_patch.unpatch()

Equivalent patch calls reuse the active handle. Conflicting configuration raises PatchConflictError. Do not unpatch while requests are in flight.

Note

Patching replaces supported Python methods inside the current process. It does not create a proxy, background thread, DNS change, or system-wide network rule.