> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloud endpoints & data residency

> The US and EU Streaming TTS endpoints for the WebSocket and HTTP APIs, where each processes your data, and how to choose one.

Streaming TTS has one endpoint per data residency zone, the US and the EU. Each one processes your text and audio in its own zone.\* Choose the zone that fits your data residency requirements, or the one nearer to your application for the lowest latency.

\*AssemblyAI will store Account Data and Usage Data in the United States, per our [Privacy Policy](https://www.assemblyai.com/legal/privacy-policy) and the Data Privacy Framework. Text and audio data will be stored in the endpoint region you select. Incident response and customer support may be conducted from locations where staff are employed, which may be in the US, EU, or elsewhere. If your text or audio needs to be accessed for debugging, a member of our team located outside of your endpoint region may access that data and may use a US-based subprocessor to support the troubleshooting or customer support request.

## Data processing locations

All Streaming TTS text and audio is processed in AWS regions located in the United States and the European Union:

**US**

| AWS region | Location |
| - | - |
| `us-east-1` | N. Virginia |

**EU**

| AWS region | Location |
| - | - |
| `eu-north-1` | Stockholm |

Which of these locations processes your data depends on the endpoint you connect to, as described below.

## Endpoints

| Endpoint | WebSocket URL | Region |
| - | - | - |
| US data residency | `wss://tts.us.assemblyai.com/v1/ws` | `us-east-1` |
| EU data residency | `wss://tts.eu.assemblyai.com/v1/ws` | `eu-north-1` |

The path, connect parameters, frames and limits are identical on both hosts. Only the host changes. An API key in the `Authorization` header and a [temporary token](https://assemblyai.com/docs/tts/authenticate-with-a-temporary-token.md) in the `token` query parameter are accepted on both hosts.

A [cloned voice](https://assemblyai.com/docs/tts/cloned-voices.md#data-zones) belongs to the data zone it was created in, and only that zone's host can use it. On the other zone's host, a session with the voice closes with `3012` `voice_not_found`.

> [!NOTE]
>
> Streaming TTS has no global endpoint yet. Connect to the US or EU endpoint:
> the one of the zone that should process your data and that holds your cloned
> voices.

## HTTP API

The [HTTP API](https://assemblyai.com/docs/tts/api-reference/http-api/overview.md) and its [OpenAI-compatible route](https://assemblyai.com/docs/tts/openai-compatibility.md) are served over HTTPS on the same hosts, in the same regions:

| Endpoint | HTTP API base URL | OpenAI SDK `base_url` |
| - | - | - |
| US data residency | `https://tts.us.assemblyai.com` | `https://tts.us.assemblyai.com/v1/openai` |
| EU data residency | `https://tts.eu.assemblyai.com` | `https://tts.eu.assemblyai.com/v1/openai` |

The HTTP routes read the credential from the `Authorization` header: an API key, or a temporary token in a browser.

## Which endpoint should I use?

* **Need US data residency?** Use the **US endpoint** (`tts.us.assemblyai.com`).
* **Need EU data residency?** Use the **EU endpoint** (`tts.eu.assemblyai.com`).
* **Using a cloned voice?** Use the endpoint of the zone the voice was created in. A voice created in one zone is only usable on that zone's endpoint.
* **No residency requirement?** Use the endpoint nearer to where your application runs, for the lowest latency. [Optimizing accuracy and latency](https://assemblyai.com/docs/tts/getting-started/optimizing-accuracy-and-latency.md#use-the-nearest-data-zone) shows what the distance costs.

## How to use it

The AssemblyAI SDKs take the host as one setting, which covers the HTTP API and the WebSocket sessions alike: `tts_base_url` in the Python SDK's settings, `ttsBaseUrl` on the JavaScript client. Without an SDK, the host is the base URL of your HTTP client, the `base_url` of an OpenAI SDK, LiveKit or Pipecat ([OpenAI compatibility](https://assemblyai.com/docs/tts/openai-compatibility.md)), or part of the WebSocket URL you open. The last two tabs are the `URL` constant from the raw WebSocket program of the [Quickstart](https://assemblyai.com/docs/tts/getting-started/quickstart.md#using-the-websocket-api-directly) and a browser's `connect()`, which passes a [temporary token](https://assemblyai.com/docs/tts/authenticate-with-a-temporary-token.md) in the query string. Everything below is on the US data zone; for the EU data zone, replace `us` with `eu`, and nothing else changes.

**Python SDK**

```python theme={null}
import assemblyai as aai

# Set the host before building a TextToSpeech or a TTSSession: each reads
# the settings when it is created.
aai.settings.tts_base_url = "https://tts.eu.assemblyai.com"

tts = aai.TextToSpeech()
```

**JavaScript SDK**

```javascript theme={null}
import { AssemblyAI } from "assemblyai";

const client = new AssemblyAI({
  apiKey: process.env.ASSEMBLYAI_API_KEY,
  ttsBaseUrl: "https://tts.eu.assemblyai.com",
});

// client.tts.synthesize(), client.tts.stream() and client.tts.session() now use the EU host.
```

**Python (WebSocket)**

```python theme={null}
# Fragment: the URL constant from the quickstart program. The imports, the
# Authorization header and the rest of main() stay exactly as they are there.
URL = (
    "wss://tts.us.assemblyai.com/v1/ws"
    "?voice_id=49c443a4-8a1d-5f7e-b70b-98bdbd9823c3&language=english"
    "&sample_rate=24000&encoding=pcm_s16le"
)
```

**JavaScript (browser)**

```javascript theme={null}
// Fragment: a browser's connect(). RATE, ws, onMessage and onClose are
// yours; fetchToken() asks your own server for a temporary token.
async function connect() {
  const params = new URLSearchParams({
    voice_id: "49c443a4-8a1d-5f7e-b70b-98bdbd9823c3",
    language: "english",
    sample_rate: String(RATE),
    encoding: "pcm_s16le",
    token: await fetchToken(),
  });
  ws = new WebSocket(`wss://tts.us.assemblyai.com/v1/ws?${params}`);
  ws.onmessage = onMessage;
  ws.onclose = onClose;
}
```

If you also use Streaming Speech-to-Text with a data zone endpoint, pick the matching Streaming TTS host so that both halves of a conversation are processed in the same zone.

## Related

* [Quickstart](https://assemblyai.com/docs/tts/getting-started/quickstart.md): the SDK programs, and the complete raw WebSocket program the Python fragment above belongs to.
* [Authenticate with a temporary token](https://assemblyai.com/docs/tts/authenticate-with-a-temporary-token.md): minting the temporary token a browser client connects with.
* [Streaming Speech-to-Text endpoints](https://assemblyai.com/docs/streaming/endpoints-and-data-zones.md): the matching US and EU hosts for speech-to-text.
