Integration
Connect OpenRouter with popular AI coding tools, set up SDKs, and configure model routing and provider preferences for your workflow.
Using with Cline (VS Code)
Cline is one of the most popular AI coding assistants for VS Code, and it has built-in support for OpenRouter. This lets you access any of the 200+ models through Cline's interface.
-
Install Cline Extension
Open VS Code, go to Extensions (Ctrl+Shift+X), and search for "Cline". Install the extension.
-
Select OpenRouter as Provider
Open Cline settings and select OpenRouter as your API provider from the dropdown menu.
-
Enter Your API Key
Paste your OpenRouter API key (starting with
sk-or-) into the API key field. -
Choose a Model
Select a model from the dropdown. Popular choices include
anthropic/claude-sonnet-4for high-quality coding andopenai/gpt-4oas a versatile alternative.
Using with Kilocode
Kilocode is another VS Code AI coding assistant that supports OpenRouter natively. The setup is very similar to Cline:
-
Install Kilocode
Search for "Kilocode" in the VS Code Extensions marketplace and install it.
-
Configure OpenRouter
Open Kilocode settings, select OpenRouter as the provider, and enter your API key.
-
Select Model
Choose your preferred model. Kilocode will show you all available OpenRouter models.
Using with Continue.dev
Continue.dev is an open-source AI code assistant for VS Code and JetBrains IDEs. To configure it with OpenRouter, edit your Continue configuration file:
{
"models": [
{
"title": "Claude Sonnet 4 (OpenRouter)",
"provider": "openai",
"model": "anthropic/claude-sonnet-4",
"apiBase": "https://openrouter.ai/api/v1",
"apiKey": "sk-or-your-api-key"
},
{
"title": "GPT-4o (OpenRouter)",
"provider": "openai",
"model": "openai/gpt-4o",
"apiBase": "https://openrouter.ai/api/v1",
"apiKey": "sk-or-your-api-key"
}
]
}
Using with Any OpenAI-Compatible Tool
Any application that supports the OpenAI API can be configured to use OpenRouter instead. The general steps are:
- Find the API base URL or endpoint setting and change it to
https://openrouter.ai/api/v1 - Enter your OpenRouter API key (starting with
sk-or-) as the API key - Set the model name using OpenRouter's model ID format (e.g.,
anthropic/claude-sonnet-4)
Python SDK Setup
For Python projects, use the official OpenAI SDK with OpenRouter:
# Install the OpenAI SDK pip install openai # Set your API key as an environment variable export OPENROUTER_API_KEY="sk-or-your-api-key"
import os from openai import OpenAI # Create a reusable client client = OpenAI( base_url="https://openrouter.ai/api/v1", api_key=os.getenv("OPENROUTER_API_KEY"), default_headers={ "HTTP-Referer": "https://your-app.com", "X-Title": "Your App Name", }, ) # Now use it like you would the OpenAI client response = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{"role": "user", "content": "Hello!"}], ) print(response.choices[0].message.content)
Node.js SDK Setup
# Install the OpenAI Node.js SDK npm install openai
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://openrouter.ai/api/v1", apiKey: process.env.OPENROUTER_API_KEY, defaultHeaders: { "HTTP-Referer": "https://your-app.com", "X-Title": "Your App Name", }, }); // Use it like the standard OpenAI client const response = await client.chat.completions.create({ model: "google/gemini-2.5-pro", messages: [{ role: "user", content: "Hello!" }], }); console.log(response.choices[0].message.content);
Model Routing and Fallbacks
OpenRouter can automatically handle model routing and provider fallbacks. You can configure this through request parameters:
response = client.chat.completions.create(
model="anthropic/claude-sonnet-4",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={
# Specify provider preferences
"provider": {
"order": ["Anthropic", "AWS Bedrock"],
"allow_fallbacks": True,
},
# Use auto-routing for best model selection
# "route": "fallback",
},
)
Provider Preferences
You can control which underlying providers OpenRouter uses for each model:
- order: Specify preferred providers in order of priority (e.g., try Anthropic first, then AWS Bedrock).
- allow_fallbacks: If your preferred providers are unavailable, allow OpenRouter to use any available provider.
- require_parameters: Only route to providers that support specific features like function calling or streaming.
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX