Key storage options
Inline keys (development only)
Store keys directly in your Traffic Policy:ngrok Vaults & Secrets (recommended)
Store keys in ngrok Vaults & Secrets—they’re encrypted at rest, never visible in your Traffic Policy, and can be rotated without redeploying:Creating secrets
Using the CLI
Using the dashboard
- Navigate to Vaults & Secrets in the ngrok Dashboard
- Create a vault if you don’t have one (for example,
ai-keys) - Create a secret in the vault (for example,
openai) - Add your provider API keys as key-value pairs
Multiple keys for failover
Configure multiple provider API keys for automatic failover when keys hit rate limits or fail:- Gateway tries the first key
- If it fails (rate limit, quota exceeded, error), tries the next key
- Continues until a key succeeds or all keys are exhausted
Key rotation
To rotate provider API keys without downtime:Deploy and monitor
Deploy the updated Traffic Policy. Monitor traffic to ensure the new key works correctly.
Multi-provider example
Security best practices
- Add authorization to your gateway when using server-side keys—see Securing Your Gateway
- Never commit provider API keys to version control
- Use ngrok secrets for all production keys
- Rotate keys regularly to minimize exposure risk
- Monitor key usage to detect anomalies
- Use different keys for different environments (dev, staging, prod)
- Set up alerts for rate limit errors to proactively add capacity
Passthrough mode
If you don’t configure any keys for a provider, the gateway forwards whatever key your SDK sends:- Development environments where each developer uses their own key
- Applications that already manage their own keys
- Quick testing without configuration changes
Next steps
- Securing Your Gateway - Add authorization when using server-side keys
- BYOK Overview - Understanding Bring Your Own Keys
- Key Selection & Failover - Intelligent key selection with CEL expressions
- Configuring Providers - Full provider setup
- CEL Functions Reference - Complete API key selection reference