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

# Unified API

> Call any model with the same request format.

The Unified API gives every supported speech to text (STT) and text to speech (TTS)
model the same endpoint pattern and request shape. Change the model in the URL to try
another provider while keeping your authentication and integration code in place.

It differs from the direct model endpoints. Direct endpoints expose each provider's
native fields. The Unified API normalizes common fields, such as `voice` and `config`,
so you can integrate once and compare models more easily.

## Why use it

| Working directly with providers           | Using the Unified API                   |
| ----------------------------------------- | --------------------------------------- |
| Provider-native request fields            | One shared request shape                |
| Provider-specific integration code        | One HTTP or WebSocket endpoint pattern  |
| Model changes can require request changes | Change the model path to compare models |
| Provider-specific error handling          | Consistent error responses              |

Use the Unified API when you want to evaluate models, keep a fallback model, or route
calls to a different region without rebuilding the request for each provider. Use the
direct endpoints when you need a model's provider-native parameters.

## Swap models by changing the URL

Unified requests use `https://api.slng.ai/v1/bridges/unmute/{tts|stt}/{model-id}`.
The model ID is the final part of the path. It determines which provider and model
receives the call.

| Model                   | Request path                                     | Route       |
| ----------------------- | ------------------------------------------------ | ----------- |
| Deepgram Nova 3         | `/v1/bridges/unmute/stt/deepgram/nova:3`         | Proxied     |
| Deepgram Nova 3 English | `/v1/bridges/unmute/stt/slng/deepgram/nova:3-en` | SLNG-hosted |
| Deepgram Aura 2 English | `/v1/bridges/unmute/tts/slng/deepgram/aura:2-en` | SLNG-hosted |

`slng/` identifies a model hosted in your region. A model ID without that prefix is
proxied to the provider. See [Which models are available](/guides/models/which-models-are-available)
for the available routes, regions, and model IDs.

## Make a request

All requests use your API key as a bearer token. For regional routing, replace
`api.slng.ai` with `{region}.api.slng.ai`. See
[Using regions in the services](/guides/regions/using-regions-in-services). If you
need a key, see [Create your API key](/guides/get-started/quickstart#create-your-api-key).

### Synthesize speech

Send text and a normalized `voice` value. The field name stays the same when you switch
models, but the voice value must belong to the selected model. This request writes the
binary audio response to `hello.wav`.

```bash Rime Arcana 3 theme={null}
curl https://api.slng.ai/v1/bridges/unmute/tts/slng/fish/tts:s2.1-pro \
  -H "Authorization: Bearer $SLNG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "16cabdb7f8d240569aff36c9e480d783",
    "text": "Hello from sunny Barcelona!"
  }' \
  --output hello.wav
```

To use Deepgram Aura 2, change the model path and send a voice it supports:

```bash Deepgram Aura 2 theme={null}
curl 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 sunny Barcelona!"
  }' \
  --output hello.wav
```

### Transcribe audio

Send a recorded file as multipart form data. The response is a JSON transcript. See
[Unified STT](/api-reference/unified-api/slng/unmute-stt-bridge/unmute-stt-bridge-websocket) for the response schema.

```bash Deepgram Nova 3 English theme={null}
curl 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"
```

<Note>
  The model comes from the URL path. Do not send a duplicate `model` field unless the
  endpoint reference requires it.
</Note>

### Stream with WebSocket

Use the same path with the `wss://` scheme when you need to stream audio or text. The
Unified API uses the same WebSocket protocol as the direct endpoints. See
[WebSockets vs HTTP](/guides/models/websockets-vs-http) for when to use each transport,
and [Unified TTS over WebSocket](/api-reference/unified-api/slng/unmute-tts-bridge/unmute-tts-bridge-websocket) for
the endpoint details.

The browser WebSocket API cannot send custom authorization headers. Authenticate from a
server-side WebSocket client, or use the query-parameter method documented by the
endpoint reference.

## Unified or direct

Both API styles call the same categories of models. This table compares the endpoint
and fields. Choose based on how much of the provider's request format you need.

|                 | Unified API                                 | Direct endpoints                                           |
| --------------- | ------------------------------------------- | ---------------------------------------------------------- |
| Path            | `/v1/bridges/unmute/{type}/{model-id}`      | `/v1/{type}/{model-id}`                                    |
| Voice selection | Shared `voice` field                        | Provider-native field, such as `reference_id` or `speaker` |
| Common options  | Shared fields, including TTS `config`       | Provider-native fields                                     |
| Best for        | Comparing, swapping, or failing over models | Using a model's native capabilities                        |

Start with [Your first request](/guides/models/your-first-request) if you are calling a
single model and need its native options. Use this guide when you want one integration
that can support several models.

## Supported parameters

The Unified API accepts shared fields. A selected model still determines which voice
names, language codes, encodings, and sample rates it accepts.

### Text to speech

| Parameter            | Required | Description                              |
| -------------------- | -------- | ---------------------------------------- |
| `text`               | Yes      | Text to synthesize.                      |
| `voice`              | No       | Voice identifier for the selected model. |
| `config.sample_rate` | No       | Output sample rate in Hz.                |
| `config.encoding`    | No       | Output encoding format.                  |
| `config.language`    | No       | Language code.                           |
| `config.speed`       | No       | Speech speed multiplier.                 |

### Speech to text

| Parameter         | Required | Description                            |
| ----------------- | -------- | -------------------------------------- |
| `audio`           | Yes      | Audio file to transcribe.              |
| `language`        | No       | Recognition language code.             |
| `sample_rate`     | No       | Input sample rate in Hz.               |
| `encoding`        | No       | Input audio encoding.                  |
| `enable_vad`      | No       | Enables voice activity detection.      |
| `enable_partials` | No       | Enables partial transcription results. |

The request shape stays the same, but provider support varies. Check the
[Unified STT reference](/api-reference/unified-api/slng/unmute-stt-bridge/unmute-stt-bridge-http) and the
selected model's reference before you rely on an optional field.

## Next steps

* [Which models are available](/guides/models/which-models-are-available) to find model IDs and routes.
* [WebSockets vs HTTP](/guides/models/websockets-vs-http) to choose a transport.
* [Unified STT](/api-reference/unified-api/slng/unmute-stt-bridge/unmute-stt-bridge-http) and [Unified TTS](/api-reference/unified-api/slng/unmute-tts-bridge/unmute-tts-bridge-http) references for parameter coverage.
* [Bring your own key](/guides/models/bring-your-own-key) to use a provider account.
