Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.slng.ai/llms.txt

Use this file to discover all available pages before exploring further.

BYOK (Bring Your Own Key) lets you pass your own upstream provider API key on TTS requests. The gateway forwards that key to the provider, so billing and rate limits run against your provider account. The SLNG gateway’s TTS cache still applies on top.

Placeholders

The snippets below use these placeholders. Replace them before running the code.
PlaceholderReplace with
SLNG_API_KEYAn SLNG API key from app.slng.ai/api-keys
YOUR_PROVIDER_KEYAn API key issued by the upstream TTS provider you are calling

How caching applies

Caching runs before the gateway forwards your request, so a cache hit never reaches the upstream provider:
  • Cache hit: the cached audio is returned and no provider billing event is generated.
  • 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

ProviderModel
CartesiaSonic 3
DeepgramAura 2
MurfFalcon
SarvamBulbul
SonioxTTS RT v1

Send a BYOK request

Add X-Slng-Provider-Key to your TTS request alongside your standard SLNG Authorization header.

HTTP

curl -X POST "https://api.slng.ai/v1/tts/sarvam/bulbul:v3" \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -H "X-Slng-Provider-Key: YOUR_PROVIDER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello from BYOK",
    "target_language_code": "en-IN",
    "speaker": "shubh",
    "model": "bulbul:v3"
  }'

WebSocket

Set X-Slng-Provider-Key as a header on the WebSocket upgrade request. The message flow after the upgrade is unchanged.
X-Slng-Provider-Key: YOUR_PROVIDER_KEY
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 gateway returns the provider’s error response with this header:
X-Slng-Auth-Source: client_key
That header tells you the failure came from your provider key, not the SLNG gateway.

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.

Billing

The upstream provider bills your account directly for BYOK requests. SLNG does not charge audio-minute fees for BYOK traffic.