Skip to content

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 documentation

Openrouter API speaks three native API dialects. Pick the base URL that matches your SDK:

SDK / protocolBase URLEndpoints
OpenAI-compatiblehttps://openrouterapi.ru/v1/chat/completions, /responses, /embeddings, /images/generations, /videos/generations, /audio/transcriptions, /tasks/{id}
Anthropic Messageshttps://openrouterapi.ru/v1/messages
Google Geminihttps://openrouterapi.ru/v1beta/models/{model}:generateContent, :streamGenerateContent

OpenAI SDK

Python
from openai import OpenAI
client = OpenAI(api_key="sk-ora-...", base_url="https://openrouterapi.ru/v1")
Node.js
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.

Python
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

Python
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

Python
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

TypeScript
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.5 or deepseek-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
curl https://openrouterapi.ru/v1/models?category=video

Found a problem in these docs? Email support@openrouterapi.ru.