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

# API Keys

> Create and manage API keys for your Muxx projects.

API keys authenticate requests to the Muxx gateway and SDK. Each project has its own keys.

## Key Types

### Live Keys

```
muxx_sk_live_xxxxxxxxxxxxxxxxxxxx
```

* Used in production
* Full logging and analytics
* Rate limits and spend caps apply

### Test Keys

```
muxx_sk_test_xxxxxxxxxxxxxxxxxxxx
```

* Used in development
* Logged separately from production
* Useful for testing without polluting prod data

## Creating Keys

1. Navigate to your project
2. Go to **Settings** → **API Keys**
3. Click **Create Key**
4. Choose Live or Test
5. Add an optional description
6. Click **Create**

<Warning>
  The full key is only shown once. Copy it immediately and store it securely.
</Warning>

## Using Keys

### Gateway

Include the key in the `X-Muxx-Api-Key` header:

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

### SDK

Pass the key when initializing:

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

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

Or use environment variable:

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

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

muxx = Muxx()  # Automatically reads MUXX_API_KEY
```

## Rotating Keys

To rotate a key without downtime:

1. Create a new key
2. Update your application to use the new key
3. Deploy the change
4. Delete the old key

## Deleting Keys

1. Go to **Settings** → **API Keys**
2. Find the key to delete
3. Click **Delete**
4. Confirm deletion

<Warning>
  Deleted keys are immediately invalidated. Any requests using the key will fail.
</Warning>

## Key Security

<AccordionGroup>
  <Accordion title="Never commit keys to git">
    Use environment variables or secret management systems.
  </Accordion>

  <Accordion title="Use different keys per environment">
    Production and staging should have separate keys.
  </Accordion>

  <Accordion title="Rotate keys regularly">
    Rotate keys periodically, especially if team members leave.
  </Accordion>

  <Accordion title="Monitor for unauthorized use">
    Check logs for unexpected requests or patterns.
  </Accordion>
</AccordionGroup>

## Key Limits

| Plan       | Keys per Project |
| ---------- | ---------------- |
| Free       | 2                |
| Pro        | 10               |
| Enterprise | Unlimited        |
