Quick Start
OpenRouter — one line
register_gateway_providers() call needed.Choose Your Gateway
| Need | Gateway | Example llm |
|---|---|---|
| Hosted access to 100+ models | OpenRouter | openrouter/anthropic/claude-3.5-sonnet or or/gpt-4 |
| Self-hosted caching, fallback, load balancing | LiteLLM Proxy | litellm-proxy/gpt-4 |
| Internal OpenAI-compatible endpoint | Custom Gateway | custom-gateway/my-model with base_url in config |
How It Works
Provider Reference
OpenRouter
| Option | Type | Default | Description |
|---|---|---|---|
api_key | str | $OPENROUTER_API_KEY | OpenRouter API key |
base_url | str | https://openrouter.ai/api/v1 | API endpoint |
extra_headers | dict | — | e.g. X-Title, HTTP-Referer for app ranking |
openrouter, or. Model IDs are prefixed with openrouter/ automatically unless already prefixed.
LiteLLM Proxy
| Option | Type | Default | Description |
|---|---|---|---|
api_key | str | $LITELLM_PROXY_API_KEY | Proxy API key |
base_url | str | $LITELLM_PROXY_BASE_URL or http://localhost:4000 | Proxy URL |
extra_headers | dict | — | Custom auth or routing headers |
litellm-proxy, llm-proxy, litellm-gateway. Model IDs are passed through unchanged.
Custom Gateway
| Option | Type | Default | Description |
|---|---|---|---|
base_url | str | required | OpenAI-compatible endpoint — raises ValueError if missing |
api_key | str | — | Optional API key |
extra_headers | dict | — | Custom headers |
custom-gateway, gateway, custom.
Explicit config["api_key"] overrides environment variables at init time.
Common Patterns
Multi-agent, different gateways:Developer Flow
Best Practices
Prefer environment variables
Prefer environment variables
Set
OPENROUTER_API_KEY or LITELLM_PROXY_API_KEY instead of hardcoding keys in config.OpenRouter for experimentation
OpenRouter for experimentation
Quick access to 100+ models with one API key — ideal for prototyping.
LiteLLM Proxy for production
LiteLLM Proxy for production
Self-hosted caching, observability, and fallback routing suit production workloads.
Custom Gateway for compliance
Custom Gateway for compliance
Use
CustomGatewayProvider when traffic must stay on an internal OpenAI-compatible proxy.extra_headers for attribution
extra_headers for attribution
OpenRouter uses
X-Title and HTTP-Referer for app ranking and routing hints.Related
OpenRouter
OpenRouter model strings and env vars
LiteLLM Proxy
Self-hosted proxy setup
LLM Endpoint Config
Environment-based endpoint configuration
Custom Provider
Register custom LLM providers

