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
python -m pip install "teenageworks[openai]"ElevenLabs
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
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 call | Routed to TeenageWorks when |
|---|---|
OpenAI audio.speech.create() | The model is a recognized TTS ID |
| ElevenLabs text-to-speech | The model is teen-v1, starts with eleven_, or uses the provider default |
Remove a patch
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.
