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

# API Keys

> Create and manage Majordomo API keys.

Majordomo API keys (`mdm_sk_...`) authenticate requests through the gateway. Every proxied request must include a valid key in the `X-Majordomo-Key` header. Usage is tracked per key.

## Managing keys in the dashboard

Create, revoke, and monitor keys from the **API Keys** section of the [Majordomo dashboard](https://app.gomajordomo.com). The dashboard shows per-key request counts, costs, and last-used timestamps.

The plaintext key is shown once at creation time. Store it in your secrets manager (AWS Secrets Manager, 1Password, GitHub Secrets, etc.).

## Managing keys via CLI

```bash theme={null}
# Create
majordomo keys create --name "Production"

# List
majordomo keys list

# Revoke
majordomo keys revoke <key-id>
```

## Using keys in requests

Pass the key in the `X-Majordomo-Key` header on every request:

```python theme={null}
client = OpenAI(
    base_url="https://gateway.gomajordomo.com/v1",
    api_key="your-openai-api-key",
    default_headers={"X-Majordomo-Key": "mdm_sk_your_key_here"},
)
```

Keys are validated on every request. Invalid or revoked keys return `401 Unauthorized`.

## Key strategy

Use separate keys for separate concerns:

| Key           | Purpose                         |
| ------------- | ------------------------------- |
| `production`  | Production application traffic  |
| `staging`     | Staging environment             |
| `dev-alice`   | Individual developer            |
| `experiments` | A/B tests and model experiments |

This gives you cost and usage breakdowns per environment or team member in the dashboard without any additional configuration.
