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

# Authentication

> Authenticate requests to Muxx APIs.

All Muxx APIs require authentication using your API key.

## API Keys

API keys look like:

```
muxx_sk_live_xxxxxxxxxxxxxxxxxxxx  # Production
muxx_sk_test_xxxxxxxxxxxxxxxxxxxx  # Testing
```

Get your API key from the [dashboard](https://muxx.dev) under Project Settings → API Keys.

## Gateway Authentication

For gateway requests, use the `X-Muxx-Api-Key` header:

```bash theme={null}
curl https://gateway.muxx.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-Muxx-Api-Key: muxx_sk_live_xxxxxxxxxxxx" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

## Management API Authentication

For management API requests, use Bearer token authentication:

```bash theme={null}
curl https://api.muxx.dev/v1/logs \
  -H "Authorization: Bearer muxx_sk_live_xxxxxxxxxxxx"
```

## SDK Authentication

### Environment Variable

```bash theme={null}
export MUXX_API_KEY="muxx_sk_live_xxxxxxxxxxxx"
```

```python theme={null}
from muxx import Muxx

muxx = Muxx()  # Reads MUXX_API_KEY automatically
```

### Direct Initialization

```python theme={null}
from muxx import Muxx

muxx = Muxx(api_key="muxx_sk_live_xxxxxxxxxxxx")
```

## Security Best Practices

<Warning>
  Never commit API keys to version control or expose them in client-side code.
</Warning>

* Store keys in environment variables
* Use secret management tools in production
* Rotate keys periodically
* Use test keys for development
