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

# Provider Keys

> Supply provider API keys through environment variables, and check them at startup.

The gateway reads provider API keys from its own environment. Each provider uses its standard variable name. The gateway never stores those keys in its config file or database.

## Variable Names

| Provider | Variable |
| - | - |
| Anthropic | `ANTHROPIC_API_KEY` |
| OpenAI | `OPENAI_API_KEY` |
| Meta (Muse models) | `META_API_KEY` |
| xAI | `XAI_API_KEY` |
| Fireworks | `FIREWORKS_API_KEY` |
| Google (Gemini models) | `GEMINI_API_KEY` |
| OpenCode Go | `OPENCODE_API_KEY` |
| OpenRouter | `OPENROUTER_API_KEY` |
| Vercel AI Gateway | `AI_GATEWAY_API_KEY` |

Any other provider in the bundled catalog uses its standard variable, such as `DEEPSEEK_API_KEY`.

```bash theme={null}
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
```

Connected subscriptions can serve a provider's models without a key. GitHub Copilot and Vercel Token Pass have no API key variable: connect them as subscriptions. See [Subscriptions](https://docs.dari.dev/gateway/subscriptions.md).

With the Fully local gateway from `dari gateway setup`, save keys with `dari accounts` (**Add an API key**) or from a script: `dari accounts key` lists which providers have one, `dari accounts key <provider> <api-key>` saves one, and `dari accounts key <provider> off` removes it. A key the provider rejects is not saved.

## Startup Check

Before it serves traffic, the gateway sends each configured key to its provider to confirm it works:

* **Rejected.** The gateway refuses to start and names each provider whose key was rejected, such as `anthropic (401)`. Fix or unset the key, then start again.
* **Could not be checked.** A provider outage or network failure leaves the key unconfirmed. The gateway logs that provider and uses the key anyway, so requests may fail until the provider recovers.
* **Missing.** The gateway warns at startup about each provider with no key. Its models are not served until a key or a subscription for that provider is set. A request that no credential on the router can serve returns `424 provider_credentials_missing`.

Only providers that a router lists are checked.

## Custom Endpoints

Keys for a custom endpoint come from the variable named in its `apiKeyEnv` setting. An endpoint with no `apiKeyEnv` is called without a key, and the gateway does not check it at startup. Set its `baseUrl` and `api` in `dari-gateway.yaml`. See [Custom Provider Endpoints](https://docs.dari.dev/gateway/configure-routers.md#custom-provider-endpoints).

```yaml theme={null}
providers:
  local:
    baseUrl: http://localhost:8000/v1
    apiKeyEnv: LOCAL_API_KEY    # export LOCAL_API_KEY before starting the gateway
```

An endpoint with an `apiKeyEnv` is checked at startup the same way as a built-in provider.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.