Skip to main content
ARouter is compatible with any library or framework that supports the OpenAI Chat Completions API. This page covers the most popular integrations.

Official SDKs

ARouter provides first-class SDKs for common languages:

Python SDK

pip install arouter

Node.js / TypeScript SDK

npm install arouter

Go SDK

go get github.com/arouter-ai/arouter-go

cURL

Direct HTTP examples

OpenAI SDK (Any Language)

Because ARouter is OpenAI-compatible, the official OpenAI SDK works out of the box. Just change base_url and api_key:
from openai import OpenAI

client = OpenAI(
    api_key="your-arouter-key",
    base_url="https://api.arouter.ai/v1"
)

response = client.chat.completions.create(
    model="openai/gpt-5.4",
    messages=[{"role": "user", "content": "Hello!"}]
)

LangChain

ARouter works with LangChain’s ChatOpenAI class:
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="anthropic/claude-sonnet-4-6",
    openai_api_key="your-arouter-key",
    openai_api_base="https://api.arouter.ai/v1",
)

response = llm.invoke("Explain quantum computing in one paragraph.")
print(response.content)

Vercel AI SDK

Use ARouter as the backend for Vercel AI SDK applications:
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const arouter = createOpenAI({
  apiKey: "your-arouter-key",
  baseURL: "https://api.arouter.ai/v1",
});

const { text } = await generateText({
  model: arouter("anthropic/claude-sonnet-4-6"),
  prompt: "Write a short poem about the ocean.",
});

console.log(text);

PydanticAI

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from openai import AsyncOpenAI

client = AsyncOpenAI(
    api_key="your-arouter-key",
    base_url="https://api.arouter.ai/v1",
)

model = OpenAIModel("openai/gpt-5.4", openai_client=client)
agent = Agent(model)

result = await agent.run("Summarize the key ideas in the Feynman Lectures.")
print(result.data)

Anthropic SDK (Native)

ARouter also provides a native Anthropic-compatible endpoint. Use the official Anthropic SDK without any OpenAI wrapper:
import anthropic

client = anthropic.Anthropic(
    api_key="your-arouter-key",
    base_url="https://api.arouter.ai/anthropic",
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude!"}],
)
print(message.content[0].text)
See Anthropic Native API for the full reference.

Google Gemini SDK (Native)

ARouter provides a Gemini-compatible endpoint for the official Google Generative AI SDK:
import google.generativeai as genai

genai.configure(
    api_key="your-arouter-key",
    client_options={"api_endpoint": "https://api.arouter.ai/gemini"}
)

model = genai.GenerativeModel("gemini-2.5-pro")
response = model.generate_content("Explain the theory of relativity simply.")
print(response.text)
See Gemini Native API for the full reference.

Other Frameworks

Any framework with an OpenAI-compatible adapter will work with ARouter. Common examples:
FrameworkIntegration Path
AutoGenSet model_client base URL
CrewAIUse OpenAICompatibleModel with ARouter base URL
LlamaIndexOpenAI LLM class with custom base URL
HaystackOpenAIChatGenerator with ARouter API key and base URL
Semantic KernelOpenAIChatCompletion with custom endpoint
For any framework not listed here, check if it supports a base_url / api_base configuration — if it does, ARouter will work.