Why use the AI Gateway?
Failover & Routing
Automatic retries on errors and timeouts. Customize the routing logic to prefer cheaper models, specific providers, or your own criteria.
One Endpoint, Many Providers
Use the same endpoint for OpenAI, Anthropic, Google, and others. Switch providers without changing your code.
Compatible With Popular SDKs
Works with official and third-party SDKs. Simply change the base URL configuration option and you’re connected.
Self-Hosted Models
Route to local models like Ollama or vLLM alongside cloud providers.
Quick example
Point your SDK at your ngrok endpoint:- Receives your request
- Selects which model and provider to use (based on request path and your configuration)
- Forwards the request with the appropriate provider API key
- If it fails, retries with the next option in your failover chain
- Returns the response
What can you do?
| Use Case | Description |
|---|---|
| Multi-provider failover | Configure OpenAI as primary, Anthropic as backup |
| Multi-key rotation | Use multiple provider API keys to avoid rate limits |
| Custom selection strategies | Define exactly how models are selected using CEL expressions |
| Cost-based routing | Route to the cheapest available model automatically |
| Access control | Restrict which providers and models clients can use |
| Self-hosted models | Route to Ollama, vLLM, or other local inference servers |
| Content modification | Redact PII, sanitize responses, or inject prompts |