> ## Documentation Index
> Fetch the complete documentation index at: https://smallestai-ff1e543d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Create an API key and authenticate requests to the Smallest AI APIs.

Every API request requires an API key in the `Authorization` header.

## Create Your API Key

<Steps>
  <Step title="Go to Settings → API Keys">
    In the [Smallest AI Console](https://app.smallest.ai/dashboard/settings/apikeys?utm_source=documentation\&utm_medium=authentication), click **API Keys** in the Settings sidebar.

    <img src="https://mintcdn.com/smallestai-ff1e543d/__rdeLT6wbSp7Z7Q/images/api-keys-page-create-button.png?fit=max&auto=format&n=__rdeLT6wbSp7Z7Q&q=85&s=2d4ea46a64bd0e72535b0c9212a5aa9d" alt="API Keys settings page with Create API Key button highlighted" width="700" style={{ borderRadius: '8px' }} data-path="images/api-keys-page-create-button.png" />
  </Step>

  <Step title="Create a new key">
    Click **Create API Key**, give it a descriptive name (e.g., `my-tts-app`), and click **Create API Key**.

    <img src="https://mintcdn.com/smallestai-ff1e543d/__rdeLT6wbSp7Z7Q/images/create-api-key-modal.png?fit=max&auto=format&n=__rdeLT6wbSp7Z7Q&q=85&s=79903400acb2d4670e286c67df3cffc0" alt="Create New API Key dialog with name field and create button" width="500" style={{ borderRadius: '8px' }} data-path="images/create-api-key-modal.png" />

    Copy the key immediately — it won't be shown again.
  </Step>

  <Step title="Set it in your environment">
    ```bash theme={null}
    export SMALLEST_API_KEY="your-api-key-here"
    ```

    Add this to your `.bashrc` or `.zshrc` to persist across sessions.
  </Step>
</Steps>

## Using Your API Key

Include your key in the `Authorization` header with every request:

```
Authorization: Bearer YOUR_API_KEY
```

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech" \
    -H "Authorization: Bearer $SMALLEST_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"text": "Authentication test", "voice_id": "magnus", "output_format": "wav"}' \
    --output test.wav
  ```

  ```python Python theme={null}
  import os
  import requests

  response = requests.post(
      "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech",
      headers={
          "Authorization": f"Bearer {os.environ['SMALLEST_API_KEY']}",
          "Content-Type": "application/json",
      },
      json={"text": "Authentication test", "voice_id": "magnus", "output_format": "wav"},
  )
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.smallest.ai/waves/v1/lightning-v3.1/get_speech",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.SMALLEST_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        text: "Authentication test",
        voice_id: "magnus",
        output_format: "wav",
      }),
    }
  );
  ```
</CodeGroup>

## Security

<Warning>
  Your API key is a secret. Never expose it in client-side code, public repositories, or browser applications.
</Warning>

* Store keys in environment variables, not in source code
* Use `.env` files locally (add `.env` to `.gitignore`)
* Rotate keys periodically via the console
* Each key tracks usage against your account quota

## Error Responses

| Status                  | Meaning                                  |
| ----------------------- | ---------------------------------------- |
| `401 Unauthorized`      | Missing or invalid API key               |
| `403 Forbidden`         | Key doesn't have access to this resource |
| `429 Too Many Requests` | Rate limit exceeded — wait and retry     |

For rate limits and concurrency details, see [Concurrency and Limits](/v4.0.0/content/api-references/concurrency-and-limits).
