Skip to main content
This page covers passing your own key per request when you call the speech APIs directly. For managed voice agents, register org-level BYOK models in the Dashboard instead — see Bring Your Own Key.
If you already have a contract with a text-to-speech provider, you can keep it. Bring Your Own Key (BYOK) lets you pass your own provider key on requests. Your key is forwarded upstream, so billing and rate limits run against your provider account, and TTS Path Optimization still applies on top.

Placeholders

The snippets below use these placeholders. Replace them before running the code.

How Path Optimization applies

TTS path optimization runs before your request is forwarded, so a cache hit never reaches the upstream provider:
  • Cache hit: the cached audio is returned, no provider call, and no billing event.
  • Cache miss: the request is sent upstream with your key, the provider bills your account, and the response is cached for future requests.

Supported providers

Send a BYOK request

Add the X-Slng-Provider-Key header alongside your standard SLNG Authorization header.

HTTP

WebSocket

Set X-Slng-Provider-Key as a header on the WebSocket upgrade request. The message flow after the upgrade is unchanged.
The browser WebSocket API does not support custom headers. Set the provider key from a server-side WebSocket client.

Error handling

HTTP

If the upstream provider rejects your key, the provider’s error response is returned with this header:
That header tells you the failure came from your provider key, not from SLNG.

WebSocket

Auth failures surface as a WebSocket error frame after the upgrade is accepted, for example backend_connection_failed, with the upstream 401 or 403 detail included.

Next steps

Pronunciation Dictionaries

How structured output helps for better TTS behaviour

Drop-in gateway

Route your existing stack through SLNG.