SDKs & base URLs
Configure the OpenAI, Anthropic and Google GenAI SDKs, LangChain, LlamaIndex, the Vercel AI SDK and coding tools to use Openrouter API.
All documentationOpenrouter API speaks three native API dialects. Pick the base URL that matches your SDK:
| SDK / protocol | Base URL | Endpoints |
|---|---|---|
| OpenAI-compatible | https://openrouterapi.ru/v1 | /chat/completions, /responses, /embeddings, /images/generations, /videos/generations, /audio/transcriptions, /tasks/{id} |
| Anthropic Messages | https://openrouterapi.ru | /v1/messages |
| Google Gemini | https://openrouterapi.ru | /v1beta/models/{model}:generateContent, :streamGenerateContent |
OpenAI SDK
from openai import OpenAI
client = OpenAI(api_key="sk-ora-...", base_url="https://openrouterapi.ru/v1")import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENROUTERAPI_API_KEY, baseURL: "https://openrouterapi.ru/v1" });Every chat model in the directory — including Claude, Gemini, DeepSeek, Qwen and Grok — works through the OpenAI SDK.
Anthropic SDK
Use the Anthropic SDK when you need Claude-specific features such as extended thinking blocks or fine-grained prompt caching.
import anthropic
client = anthropic.Anthropic(api_key="sk-ora-...", base_url="https://openrouterapi.ru")
msg = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize the benefits of prompt caching."}],
)
print(msg.content[0].text)Google GenAI SDK
from google import genai
from google.genai import types
client = genai.Client(api_key="sk-ora-...", http_options=types.HttpOptions(base_url="https://openrouterapi.ru"))
resp = client.models.generate_content(model="gemini-3.5-flash", contents="Write a tagline for a sailing school.")
print(resp.text)LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-5.5", api_key="sk-ora-...", base_url="https://openrouterapi.ru/v1")
print(llm.invoke("Hello!").content)Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const openrouterapi = createOpenAI({ apiKey: process.env.OPENROUTERAPI_API_KEY, baseURL: "https://openrouterapi.ru/v1" });
const { text } = await generateText({ model: openrouterapi.chat("claude-sonnet-4-6"), prompt: "Hello!" });Coding tools and agents
Most coding assistants accept a custom OpenAI-compatible provider. Use these values:
- Base URL:
https://openrouterapi.ru/v1 - API key: your
sk-ora-key - Model: any chat model id, for example
claude-opus-4-8,gpt-5.5ordeepseek-v4-pro
For tools that use the Anthropic protocol (for example Claude Code), set ANTHROPIC_BASE_URL=https://openrouterapi.ru and ANTHROPIC_API_KEY=sk-ora-....
Listing models from code
GET /v1/models returns every model id in the OpenAI list format and does not require a key. Add ?category=image to filter.
curl https://openrouterapi.ru/v1/models?category=videoFound a problem in these docs? Email support@openrouterapi.ru.