When to use BYOK
- You already have provider accounts and billing relationships
- You need specific provider plans or tiers (enterprise agreements, committed-use discounts)
- You want to use providers beyond OpenAI and Anthropic (Google, DeepSeek, OpenRouter, etc.)
- You want to use custom or self-hosted providers (Ollama, vLLM)—see Custom Providers
- You need fine-grained control over which provider keys are used (CEL-based key selection)
- You want to manage your own cost allocation per key
How BYOK works
- Store your provider API keys in ngrok Vaults & Secrets
- Reference them in your AI Gateway Traffic Policy
- The gateway uses your keys instead of ngrok’s managed keys
AI Gateway API Keys compared to BYOK
| AI Gateway API Keys | BYOK | |
|---|---|---|
| Provider accounts needed | No (OpenAI & Anthropic only) | Yes |
| Credits required | Yes (processing fee + upstream provider fee) | No |
| Provider billing | Included in credits (ngrok pays provider) | Direct with providers |
| Setup complexity | Low (create key, use it) | Medium (configure secrets, Traffic Policy) |
| Key rotation | Managed by ngrok (provider keys) | You manage |
| Multi-key failover | Automatic | Configurable |
| CEL key selection | Not applicable | Full control |
| Custom/self-hosted providers | Not supported | Supported |
| Auth | Built-in (AI Gateway API Key) | DIY (secrets, JWT, etc.) |
| Supported providers | OpenAI, Anthropic | Any provider |
Mixed mode
You can combine both approaches in the same gateway. Use AI Gateway API Keys for OpenAI and Anthropic while bringing your own keys for other providers. When you authenticate with an AI Gateway API Key, BYOK keys take precedence for providers where they’re configured. See AI Gateway API Keys—Mixed mode for details.Guides
Configuring Providers
Set up providers, models, and API keys in your Traffic Policy
Managing Provider Keys
Store, rotate, and manage your provider API keys
Key Selection & Failover
Advanced CEL-based key selection strategies
Securing Endpoints
Add authorization when using your own provider keys