AI Gateway API keys are the simplest way to start using the AI Gateway. Create a key, add it to your SDK configuration, and start making requests—ngrok handles the provider accounts and API keys for OpenAI and Anthropic on your behalf.Documentation Index
Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Need providers beyond OpenAI and Anthropic, or already have your own provider accounts? See Bring Your Own Keys.
Getting started
- Create an AI Gateway if you haven’t already
- Purchase credits—AI Gateway API Keys require prepaid credits to work
- Create an API key from your gateway’s API Keys tab in the dashboard
- Update your SDK with both the gateway URL and your key:
When to use AI Gateway API Keys
Use AI Gateway API Keys when you want to:- Get started quickly: no provider accounts or billing setup needed
- Use OpenAI or Anthropic: these are the currently supported providers
- Keep things simple: built-in auth means no need to configure secrets or Traffic Policy rules
- Let ngrok handle key management: no provider keys to rotate or secure
AI Gateway API Keys work with OpenAI and Anthropic only. For Google, DeepSeek, self-hosted models, and other providers, use Bring Your Own Keys. You can use both in the same gateway.
Creating keys
Dashboard
- Navigate to AI Gateways in the dashboard
- Select your gateway
- Go to the API Keys tab
- Click New API Key
- Copy the token immediately—it won’t be shown again
CLI
API
Managing keys
| Operation | CLI | API |
|---|---|---|
| List | ngrok api ai-gateway-api-keys list | GET /ai_gateway_api_keys |
| Get | ngrok api ai-gateway-api-keys get <id> | GET /ai_gateway_api_keys/{id} |
| Update | ngrok api ai-gateway-api-keys update <id> | PATCH /ai_gateway_api_keys/{id} |
| Delete | ngrok api ai-gateway-api-keys delete <id> | DELETE /ai_gateway_api_keys/{id} |
Things to know
Your key token is only shown once
When you create a key, the token (starting withng-) is displayed exactly once. Store it somewhere safe. If you lose it, delete the key and create a new one.
Keys require credits
AI Gateway API Keys require prepaid credits. Credits cover ngrok’s processing fee plus the upstream provider cost (OpenAI, Anthropic). When credits run out, keys stop working until you purchase more.Each key is tied to one gateway
A key only works with the specific AI Gateway it was created for. If you use it with a different gateway, you’ll get an error.Invalid keys are rejected, not passed through
If you send a request with a malformed or deleted AI Gateway API Key, the request is rejected immediately. It won’t silently fall through to another authentication method. See Troubleshooting for error codes.You can use ngrok/auto for automatic model selection
Set model: "ngrok/auto" and the gateway picks the best available model from OpenAI and Anthropic—no provider configuration needed:
Attaching your own provider keys
Attach your own provider API keys directly to an AI Gateway API Key. ngrok encrypts them at rest and uses them automatically when routing requests. When you authenticate with an AI Gateway API Key, the gateway selects a provider key for each provider as follows:- Keys you’ve attached to the AI Gateway API Key: used exclusively when present for that provider
- Provider keys in your Traffic Policy (
providers[].api_keys): deprecated for standard providers, still required for custom or self-hosted providers; used only when no attached key exists for that provider - ngrok-managed keys: fallback for OpenAI and Anthropic (requires credits)
Mixing AI Gateway API Keys with your own provider keys
You can use both AI Gateway API Keys and Bring Your Own Keys in the same gateway. This is useful when you want ngrok to handle OpenAI and Anthropic, but you also need access to other providers like Google. When you authenticate with an AI Gateway API Key:- OpenAI and Anthropic use ngrok’s managed keys automatically
- Any provider where you’ve configured your own keys uses those instead
How AI Gateway API Keys differ from other ngrok credentials
ngrok has several types of credentials, and it’s easy to mix them up:| Credential | What it’s for |
|---|---|
| AI Gateway API Keys | Your app uses these to make AI requests through the gateway |
| ngrok API Keys | You use these to manage ngrok resources via the management API |
| ngrok Authtokens | ngrok agents use these to connect to the platform |
| Provider API Keys | Keys from OpenAI, Anthropic, etc.—only needed with BYOK |
Next steps
- Credits: Understand how usage is billed
- Quickstart: Get started in minutes
- Securing Endpoints: How AI Gateway API Keys secure your gateway
- Bring Your Own Keys: Use your own provider API keys