> ## 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.

# SLNG Unified API

> The SLNG Unified API gives you one request format for every STT and TTS model. Swap Deepgram, Rime, Cartesia, and more by changing the URL.

One endpoint pattern for every STT and TTS model on the platform. Switch providers by changing the URL path. Your code, auth, and request format don't change.

## Swap models by changing the URL

Every request uses the same base URL. The only part that changes is the model path:

|                               | Base URL                             | Model path                    |
| ----------------------------- | ------------------------------------ | ----------------------------- |
| Deepgram Nova 3 (proxied)     | `api.slng.ai/v1/bridges/unmute/stt/` | **`deepgram/nova:3`**         |
| Deepgram Nova 3 (SLNG-hosted) | `api.slng.ai/v1/bridges/unmute/stt/` | **`slng/deepgram/nova:3-en`** |
| Deepgram Aura 2               | `api.slng.ai/v1/bridges/unmute/tts/` | **`slng/deepgram/aura:2-en`** |
| Rime Arcana v3                | `api.slng.ai/v1/bridges/unmute/tts/` | **`slng/rime/arcana:3-en`**   |

Authentication, request body, and response format are identical. Only the path differs.

## Why a unified interface

Most voice AI stacks lock you into one provider's SDK, request format, and response structure. The Unified API removes that friction.

| Without SLNG Unified API                | With SLNG Unified API                          |
| --------------------------------------- | ---------------------------------------------- |
| One SDK per provider                    | One HTTP/WebSocket endpoint for all            |
| Different request schemas               | Same request body across providers             |
| Provider-specific error handling        | Consistent error responses                     |
| Weeks to evaluate a new model           | Change the URL path, test immediately          |
| Manual upgrades when better models ship | New models available as soon as SLNG adds them |

Common patterns:

* **A/B testing**: route a percentage of traffic to a different model path with no code change.
* **Failover**: switch providers by changing the model path; request format and error handling stay the same.
* **Latency optimization**: deploy across regions and route each one to the lowest-latency model.
* **Rapid prototyping**: try a new model by changing the URL.

The Unified API doesn't hide provider capabilities. Pass voice identifiers, sample rates, encodings, language codes, and speed settings through the `config` object. See [Parameters coverage](/execution-layer/unified-api-parameters) for the full list.

## Works over HTTP and WebSocket

The same model path works with both protocols:

| Protocol  | URL                                                                 |
| --------- | ------------------------------------------------------------------- |
| HTTP      | `https://api.slng.ai/v1/bridges/unmute/tts/slng/deepgram/aura:2-en` |
| WebSocket | `wss://api.slng.ai/v1/bridges/unmute/tts/slng/deepgram/aura:2-en`   |

Use HTTP for batch jobs and file conversion. Use WebSocket for real-time streaming and voice agents. See [HTTP vs. WebSocket](/protocols) for details.

## Get started

### Prerequisites

* An SLNG key ([get one here](https://app.slng.ai/api-keys))
* `curl` installed (or any HTTP client)

### Authentication

All requests require a Bearer token:

```bash theme={null}
Authorization: Bearer SLNG_API_KEY
```

### Text-to-Speech

Generate speech from text. Here's a request using Rime Arcana v3:

```bash theme={null}
curl -X POST https://api.slng.ai/v1/bridges/unmute/tts/slng/rime/arcana:3-en \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voice": "luna",
    "text": "Hello from the SLNG Unified API!"
  }' \
  --output hello.wav
```

This saves a WAV file. You can set encoding and sample rate through the `config` object.

To make acronyms, product names, and domain terms speak consistently across TTS models, attach a [pronunciation dictionary](/pronunciation-dictionaries) to the request.

<Note>
  The model is inferred from the URL path. Do not include a duplicate `model` field in the request body unless an endpoint reference explicitly requires it.
</Note>

Switch to Deepgram Aura 2 by changing the URL path and adapting the voice.

```bash highlight={1} theme={null}
curl -X POST https://api.slng.ai/v1/bridges/unmute/tts/slng/deepgram/aura:2-en \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voice": "aura-2-asteria-en",
    "text": "Hello from the SLNG Unified API!"
  }' \
  --output hello.wav
```

### Speech-to-Text

Transcribe audio with SLNG-hosted Deepgram Nova 3:

```bash theme={null}
curl -X POST https://api.slng.ai/v1/bridges/unmute/stt/slng/deepgram/nova:3-en \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -F "audio=@recording.wav" \
  -F "language=en"
```

Switch to proxied Deepgram Nova 3 for 17-language coverage. Only the URL changes:

```bash highlight={1} theme={null}
curl -X POST https://api.slng.ai/v1/bridges/unmute/stt/deepgram/nova:3 \
  -H "Authorization: Bearer SLNG_API_KEY" \
  -F "audio=@recording.wav" \
  -F "language=en"
```

### WebSocket streaming

The same model paths work over WebSocket for real-time streaming. Connect to `wss://` instead of posting to `https://`.

<Note>
  The browser WebSocket API does not support custom headers. Pass the SLNG key as a query parameter or use a server-side WebSocket client. The example below uses the Node.js `ws` library.
</Note>

```javascript theme={null}
import WebSocket from "ws";

const ws = new WebSocket(
  "wss://api.slng.ai/v1/bridges/unmute/tts/slng/deepgram/aura:2-en",
  { headers: { Authorization: "Bearer SLNG_API_KEY" } }
);

ws.on("open", () => {
  ws.send(JSON.stringify({
    voice: "aura-2-asteria-en",
    text: "Streaming audio in real time."
  }));
});

ws.on("message", (data) => {
  // Binary frames contain audio chunks
  if (Buffer.isBuffer(data)) {
    process.stdout.write(data);
  }
});
```

For browser-based WebSocket examples, see [TTS over WebSocket](/examples/tts-websocket).

## Next steps

<CardGroup cols={3}>
  <Card title="Parameters coverage" icon="table-properties" href="/execution-layer/unified-api-parameters">
    See which parameters each provider supports.
  </Card>

  <Card title="Supported models" icon="cpu" href="/execution-layer/unified-api-models">
    Browse all models available through the Unified API.
  </Card>

  <Card title="HTTP vs. WebSocket" icon="arrow-left-right" href="/protocols">
    When to use each protocol and their trade-offs.
  </Card>
</CardGroup>
