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

# Authentication

> Authenticate every SLNG API request with your API key as a bearer token.

Every request carries one credential: your API key, sent as an `Authorization: Bearer` header. The same key works across every surface of the API.

```text theme={null}
Authorization: Bearer $SLNG_API_KEY
```

## Get an API key

Create a key on the [Projects page](https://app.slng.ai/projects) in the dashboard. [Create your API key](https://docs.slng.ai/guides/get-started/quickstart.md#create-your-api-key) walks through it: start a new project, then choose **Generate key**. Copy the key while the dialog shows it, because it appears only once.

## Send the key

Set the key in your environment, then send it as a bearer token on every request:

```bash theme={null}
export SLNG_API_KEY="slng_..."
```

```bash curl highlight={2} theme={null}
curl https://eu-west.api.slng.ai/v1/tts/slng/fish/tts:s2.1-pro \
  -H "Authorization: Bearer $SLNG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Hello from SLNG.", "reference_id": "16cabdb7f8d240569aff36c9e480d783" }' \
  --output hello.mp3
```

Over WebSocket, send the same header in the connection upgrade request. [WebSockets vs HTTP](https://docs.slng.ai/guides/models/websockets-vs-http.md) covers when to use each.

A key works only in the region of the project it belongs to. Send requests to that region's base URL, `https://{region}.api.slng.ai`. Another region's base URL answers `401`. See [Use the key in its region](https://docs.slng.ai/guides/get-started/create-a-project/your-own-code.md#use-the-key-in-its-region) and [Regions and base URLs](https://docs.slng.ai/guides/regions/regions-map.md#regions-and-base-urls).

## Where the key works

The API key authenticates every SLNG surface:

| Surface | Base URL |
| - | - |
| Speech and unified endpoints | `{region}.api.slng.ai`, in the key's region |
| Context Router | `{region}.context-router.slng.ai/v1`, in the key's region |
| Agents control plane | `api.agents.slng.ai` |
| Account API | `{region}.api.slng.ai`, in the key's region |
| Batch API | `api.batch.slng.ai` |

The Batch API also accepts the key in an `X-API-Key` header, which is equivalent to the bearer header. Keys start with `slng_cu_` for consumer keys or `slng_bt_` for batch keys.

## Keep keys safe

* Store the key in a secret manager or an environment variable. Keep it out of source control and browser code.
* Set an expiration when you create a key, and rotate by generating a new one.
* To revoke a leaked key, delete it in the dashboard and issue a replacement.

Provider keys for [bring your own key](https://docs.slng.ai/guides/models/bring-your-own-key.md) are separate. You manage those in the dashboard and still authenticate to SLNG with your SLNG API key.

## When authentication fails

A request without a valid key returns `401` with the standard error body. See [Error codes](https://docs.slng.ai/api-reference/error-codes.md) for the shape and the full list.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.