Placeholders
The snippets below use these placeholders. Replace them before running the code.| Placeholder | Replace with |
|---|---|
SLNG_API_KEY | An SLNG key from app.slng.ai/api-keys |
YOUR_PROVIDER_KEY | A provider key issued by the upstream TTS provider you are calling |
How output assembly applies
Assembly 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 theX-Slng-Provider-Key header alongside your standard SLNG Authorization header.
HTTP
WebSocket
SetX-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:WebSocket
Auth failures surface as a WebSocket error frame after the upgrade is accepted, for examplebackend_connection_failed, with the upstream 401 or 403 detail included.
Billing
The upstream provider bills your account directly for BYOK requests. No audio-minute fees apply to BYOK traffic.Next steps
Output assembly
How assembled-from-cache output cuts cost and latency on repeated text.
Drop-in gateway
Route your existing stack through SLNG.