RouteLM Documentation
Complete developer guide for integrating RouteLM's unified OpenAI & Anthropic compatible AI gateway into your apps, IDEs, and tools.
Quickstart & Endpoints
RouteLM provides standard OpenAI and Anthropic compatible HTTP endpoints. Set your Base URL to:
Available Completion Endpoints
POST https://routelm.dev/v1/chat/completions
For OpenAI SDKs, Cursor AI, LangChain, Aider, and standard tools.
POST https://routelm.dev/v1/messages
For Anthropic SDKs, Claude Code CLI, and native Anthropic tools.
auto for automated model routing. However, you can also specify any individual model ID listed on your User Models Page (e.g. gpt-4o, claude-3-5-sonnet, deepseek-v3).
Authentication
All API requests require a valid RouteLM API key passed in the standard HTTP Authorization header:
You can generate and manage your API keys anytime from your User Dashboard Keys Page.
SDK Integrations
Python (OpenAI SDK)
Change just base_url and api_key in the official openai Python package:
from openai import OpenAI client = OpenAI( base_url="https://routelm.dev/v1", api_key="rlm-live-your-api-key-here" ) response = client.chat.completions.create( model="auto", messages=[{"role": "user", "content": "Explain quantum computing in simple terms."}] ) print(response.choices[0].message.content)
Python (Anthropic SDK)
RouteLM natively proxy-translates Anthropic SDK requests:
import anthropic client = anthropic.Anthropic( base_url="https://routelm.dev/v1", api_key="rlm-live-your-api-key-here" ) response = client.messages.create( model="auto", max_tokens=1024, messages=[{"role": "user", "content": "Write a Python function for binary search."}] ) print(response.content[0].text)
Node.js / TypeScript
import OpenAI from 'openai'; const openai = new OpenAI({ baseURL: 'https://routelm.dev/v1', apiKey: 'rlm-live-your-api-key-here', }); async function main() { const completion = await openai.chat.completions.create({ messages: [{ role: 'user', content: 'Hello RouteLM!' }], model: 'auto', }); console.log(completion.choices[0].message.content); } main();
cURL / REST API
curl https://routelm.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rlm-live-your-api-key-here" \
-d '{
"model": "auto",
"messages": [
{
"role": "user",
"content": "Hello RouteLM!"
}
]
}'
IDE & Tool Integration Guides
Connect RouteLM to your favorite AI code editors, terminal tools, and LLM frameworks in less than 2 minutes.
⚡ 1. Cursor AI Setup
- Open Cursor Settings (Click gear icon in top right or press
Cmd/Ctrl + ,). - Navigate to Cursor Settings → Models.
- Under OpenAI API Key, click Override OpenAI Base URL.
- Enter Base URL:
https://routelm.dev/v1 - Paste your RouteLM API Key:
rlm-live-xxxxxxxx - Add custom model name:
auto.
💡 2. Continue.dev Setup
Open your Continue configuration file at ~/.continue/config.json and add RouteLM to the models list:
{
"models": [
{
"title": "RouteLM Auto",
"provider": "openai",
"model": "auto",
"apiKey": "rlm-live-your-api-key-here",
"apiBase": "https://routelm.dev/v1"
}
]
}
🤖 3. Claude Code CLI Setup
Set environment variables in your terminal shell profile (~/.zshrc or ~/.bashrc):
export ANTHROPIC_BASE_URL="https://routelm.dev" export ANTHROPIC_API_KEY="rlm-live-your-api-key-here" export CLAUDE_CODE_SKIP_FAST_MODE_ORG_CHECK=1 export CLAUDE_CODE_MAX_CONTEXT_TOKENS=128000 export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 # Then run Claude Code with your desired model: claude --model auto # Or specify a direct model: claude --model deepseek-v4-flash
⚙️ 4. Zed Editor Setup
Open Zed settings (~/.config/zed/settings.json) and add the OpenAI language model configuration:
{
"language_models": {
"openai": {
"api_url": "https://routelm.dev/v1",
"available_models": [
{
"name": "auto",
"max_tokens": 128000
}
]
}
}
}
💻 5. OpenCode Setup
Export the standard OpenAI environment variables in your terminal:
export OPENAI_BASE_URL="https://routelm.dev/v1" export OPENAI_API_KEY="rlm-live-your-api-key-here"
🛠️ 6. Aider AI Setup
Launch Aider pairing assistant with RouteLM's endpoint:
export OPENAI_API_BASE="https://routelm.dev/v1" export OPENAI_API_KEY="rlm-live-your-api-key-here" # Run Aider with RouteLM auto model aider --model openai/auto
🦜🔗 7. LangChain & LlamaIndex Setup
Pass base_url to standard ChatOpenAI or OpenAI LLM instances:
from langchain_openai import ChatOpenAI llm = ChatOpenAI( base_url="https://routelm.dev/v1", api_key="rlm-live-your-api-key-here", model="auto" ) response = llm.invoke("Hello from LangChain!") print(response.content)
💬 8. LibreChat / AnythingLLM Setup
Configure your web UI environment variables in docker-compose.yml or .env:
OPENAI_REVERSE_PROXY=https://routelm.dev/v1 OPENAI_API_KEY=rlm-live-your-api-key-here
Streaming & Server-Sent Events (SSE)
RouteLM supports full Server-Sent Events (SSE) streaming. Pass "stream": true in your payload to receive real-time chunked tokens.
curl https://routelm.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rlm-live-your-api-key-here" \
-d '{
"model": "auto",
"stream": true,
"messages": [{"role": "user", "content": "Write a short story."}]
}'
Rate Limits & Error Handling
RouteLM returns standard HTTP status codes for all requests:
| Status Code | Meaning & Resolution |
|---|---|
| 200 OK | Request completed successfully. |
| 401 Unauthorized | Missing or invalid API key. Verify your Bearer token in the header. |
| 402 Payment Required | Insufficient account credit balance. Please top up your wallet in the dashboard. |
| 403 Forbidden | Account under review or suspended. Contact support at [email protected]. |
| 429 Rate Limited | Exceeded requests per minute (60 RPM Free Tier, 180 RPM Paid Tier). Retry after backing off. |
| 500 Server Error | Internal gateway error. Automatic failover automatically redirects traffic when applicable. |