> ## 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. [How to set up](/guides/get-started/quickstart#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_..."
```

<CodeGroup>
  ```bash curl highlight={2} theme={null}
  curl https://eu-west.slng.ai/v1/tts/slng/deepgram/aura:2-en \
    -H "Authorization: Bearer $SLNG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "model": "aura-2-thalia-en", "text": "Hello from SLNG." }' \
    --output hello.mp3
  ```
</CodeGroup>

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

Regional hosts take the same key. Swap `api.slng.ai` for a regional base URL such as `eu-west.api.slng.ai` to run the request in that region.

## Where the key works

The API key authenticates every SLNG surface:

| Surface                            | Base URL                                                |
| ---------------------------------- | ------------------------------------------------------- |
| Speech, LLM, and unified endpoints | `api.slng.ai` and regional hosts `<region>.api.slng.ai` |
| Agents control plane               | `api.agents.slng.ai`                                    |
| Account API                        | `api.slng.ai`                                           |
| 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](/guides/models/bring-your-own-key) 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](/api-reference/error-codes) for the shape and the full list.
