Configure the master key
Setmaster_key under general_settings in config.yaml:
LITELLM_MASTER_KEY environment variable at boot.
For local Docker Compose, the default master key is sk-local. Change it by setting LITELLM_MASTER_KEY in your .env file.
Supported header formats
The gateway accepts the master key in two header styles:| Priority | Header | Format |
|---|---|---|
| 1 | Authorization | Bearer <key> |
| 2 | x-api-key | raw key, no prefix |
Response codes
| Case | Status |
|---|---|
| Key matches | Request proceeds |
| Key wrong or missing (master key is set) | 401 Unauthorized |
| No master key configured | Request proceeds (auth disabled) |
401 returns:
Key separation
The master key authenticates callers to the gateway. It is separate from the provider API keys the gateway uses to call upstream LLMs. Provider keys are stored encrypted in the credentials vault and never exposed to callers.Per-user keys (teams)
For team access, issue per-user virtual keys instead of sharing the master key. In Settings → Keys, click New Key and set budget limits, model restrictions, and expiry.Authorization: Bearer <virtual-key> — they never see the master key or any provider credential.