[metadata]
apple-mobile-web-app-title: OpenRouter | Documentation
application-name: OpenRouter | Documentation
description: Get started with OpenRouter
generator: Mintlify
msapplication-TileColor: #7624F4
msapplication-config: /docs/_mintlify/favicons/openrouter-d02e98a0/EmhfYwFO2tvnkuV-/_generated/favicon/browserconfig.xml
og:description: Get started with OpenRouter's unified API for hundreds of AI models. Learn how to integrate using the API directly, the Client SDKs, or the Agent SDK.
og:image: https://openrouter.ai/dynamic-og?pathname=quickstart&title=Quick%20Start&description=Start%20using%20OpenRouter%20API%20in%20minutes%20with%20any%20SDK
og:image:height: 630
og:image:width: 1200
og:site_name: OpenRouter Documentation
og:title: OpenRouter Quickstart Guide
og:type: website
og:url: https://openrouter.ai/docs/quickstart
twitter:card: summary_large_image
twitter:description: Get started with OpenRouter's unified API for hundreds of AI models. Learn how to integrate using the API directly, the Client SDKs, or the Agent SDK.
twitter:image: https://openrouter.ai/dynamic-og?pathname=quickstart&title=Quick%20Start&description=Start%20using%20OpenRouter%20API%20in%20minutes%20with%20any%20SDK
twitter:image:height: 630
twitter:image:width: 1200
twitter:title: OpenRouter Quickstart Guide
viewport: width=device-width, initial-scale=1, viewport-fit=cover

[canonical-links]
https://openrouter.ai/docs/quickstart

[document-links]
/docs/llms.txt: /docs/llms.txt
API Reference: /docs/api_reference/overview
Agent SDK documentation: /docs/agent-sdk/overview
Agent SDK: /docs/agent-sdk/overview
Anthropic Agent SDK: /docs/guides/community/anthropic-agent-sdk
App Attribution guide: /docs/app-attribution
App Attribution: /docs/app-attribution
Apps: https://openrouter.ai/apps
Arize AX: /docs/guides/community/arize
Auto Exacto: /docs/guides/routing/auto-exacto
Awesome OpenRouter: /docs/guides/community/awesome-openrouter
Batch Beta: /docs/batch-quickstart
Batch: /docs/batch-quickstart
Benchmarks: https://openrouter.ai/benchmarks
Chat: https://openrouter.ai/chat
Client SDKs documentation: /docs/client-sdks/overview
Client SDKs: /docs/client-sdks/overview
Cookbook: /docs/cookbook/get-started/quickstart
Custom Classifiers: /docs/guides/features/classifiers
Data Collection: /docs/guides/privacy/data-collection
Docs: /docs/quickstart
Docs: https://openrouter.ai/docs
Effect AI SDK: /docs/guides/community/effect-ai-sdk
FAQ: /docs/faq
FAQ: /docs/faq#how-are-rate-limits-calculated
For Providers: /docs/guides/community/for-providers
Frameworks and Integrations Overview: /docs/guides/community/frameworks-and-integrations-overview
GET /api/v1/models: /docs/api/api-reference/models/list-all-models-and-their-properties
Infisical: /docs/guides/community/infisical
Input & Output Logging: /docs/guides/features/input-output-logging
LangChain: /docs/guides/community/langchain
Langfuse: /docs/guides/community/langfuse
Latency and Performance: /docs/guides/best-practices/latency-and-performance
LiveKit: /docs/guides/community/livekit
MCP server guide: /docs/guides/overview/mcp-server
MCP: /docs/guides/overview/mcp-server
Mastra: /docs/guides/community/mastra
Message Transforms: /docs/guides/features/message-transforms
Model Fallbacks: /docs/guides/routing/model-fallbacks
Models: /docs/guides/overview/models
Models: https://openrouter.ai/models
OpenAI SDK: /docs/guides/community/openai-sdk
OpenRouter MCP server: /docs/guides/overview/mcp-server
OpenRouter | Documentation home page: https://openrouter.ai
Ori Eval: /docs/guides/ori/eval
Ori Harness: /docs/guides/ori/harness
Presets: /docs/guides/features/presets
Principles: /docs/guides/overview/principles
Private Models: /docs/guides/routing/private-models
Prompt Caching: /docs/guides/best-practices/prompt-caching
Provider Logging: /docs/guides/privacy/provider-logging
Provider Selection: /docs/guides/routing/provider-selection
PydanticAI: /docs/guides/community/pydantic-ai
Quickstart: /docs/quickstart
Rankings: https://openrouter.ai/rankings
Reasoning Tokens: /docs/guides/best-practices/reasoning-tokens
Render: /docs/guides/community/render
Replit: /docs/guides/community/replit
Report Feedback: /docs/guides/overview/report-feedback
Request Builder: https://openrouter.ai/request-builder
Response Caching: /docs/guides/features/response-caching
Router Metadata: /docs/guides/features/router-metadata
SCIM Group Mappings: /docs/guides/features/scim-mappings
Service Tiers: /docs/guides/features/service-tiers
Single Sign-On (SSO): /docs/guides/features/sso
Sovereign AI: /docs/guides/features/sovereign-ai
Stripe Projects: /docs/guides/overview/stripe-projects
Structured Outputs: /docs/guides/features/structured-outputs
Switching Workspaces: /docs/guides/features/workspaces/switching
TanStack AI: /docs/guides/community/tanstack-ai
Tool Calling: /docs/guides/features/tool-calling
Uptime Optimization: /docs/guides/best-practices/uptime-optimization
Vercel AI SDK: /docs/guides/community/vercel-ai-sdk
Where Ori writes files: /docs/guides/ori/files
Workspace Budgets: /docs/guides/features/workspaces/workspace-budgets
Workspaces: /docs/guides/features/workspaces
Xcode: /docs/guides/community/xcode
ZDR: /docs/guides/features/zdr
Zapier: /docs/guides/community/zapier
Zero Completion Insurance: /docs/guides/features/zero-completion-insurance
latest alias: /docs/guides/routing/routers/latest-resolution
openrouter.ai/models: https://openrouter.ai/models
see our frameworks documentation.: /docs/guides/community/frameworks-and-integrations-overview
streaming: /docs/api_reference/streaming

[structured-data]
{"@context":"https://schema.org","@graph":[{"@id":"https://openrouter.ai/#organization","@type":"Organization","logo":{"@type":"ImageObject","url":"https://mintcdn.com/openrouter-d02e98a0/ksNSeB_K7gD-BUDh/assets/logo-v2-light.svg?fit=max&auto=format&n=ksNSeB_K7gD-BUDh&q=85&s=690e45873843519efe02bcbe45795dac"},"name":"OpenRouter | Documentation","url":"https://openrouter.ai"},{"@id":"https://openrouter.ai/docs#website","@type":"WebSite","name":"OpenRouter | Documentation","publisher":{"@id":"https://openrouter.ai/#organization"},"url":"https://openrouter.ai/docs"},{"@id":"https://openrouter.ai/docs/quickstart#webpage","@type":"WebPage","breadcrumb":{"@id":"https://openrouter.ai/docs/quickstart#breadcrumb"},"dateModified":"2026-08-08T19:05:56.234Z","description":"Get started with OpenRouter","isPartOf":{"@id":"https://openrouter.ai/docs#website"},"name":"Quickstart","url":"https://openrouter.ai/docs/quickstart"},{"@id":"https://openrouter.ai/docs/quickstart#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","item":"https://openrouter.ai/docs","name":"OpenRouter | Documentation","position":1},{"@type":"ListItem","item":"https://openrouter.ai/docs/quickstart","name":"Quickstart","position":2}]},{"@id":"https://openrouter.ai/docs/quickstart#article","@type":["Article","TechArticle"],"dateModified":"2026-08-08T19:05:56.234Z","description":"Get started with OpenRouter","headline":"Quickstart","image":"https://openrouter.ai/dynamic-og?pathname=quickstart&title=Quick%20Start&description=Start%20using%20OpenRouter%20API%20in%20minutes%20with%20any%20SDK","isPartOf":{"@id":"https://openrouter.ai/docs#website"},"mainEntityOfPage":{"@id":"https://openrouter.ai/docs/quickstart#webpage"},"name":"Quickstart","publisher":{"@id":"https://openrouter.ai/#organization"},"url":"https://openrouter.ai/docs/quickstart"}]}

[content]
OpenRouter Quickstart Guide
Documentation Index
Fetch the complete documentation index at:
/docs/llms.txt
Use this file to discover all available pages before exploring further.
Skip to main content
OpenRouter | Documentation
home page
Search...
⌘
K
Ask Assistant
Models
Benchmarks
Chat
Rankings
Apps
Docs
Search...
Navigation
Overview
Quickstart
Docs
API Reference
Client SDKs
Agent SDK
Cookbook
Overview
Quickstart
Batch
Beta
Principles
Models
MCP
Multimodal
Authentication
Stripe Projects
FAQ
Report Feedback
Models & Routing
Model Fallbacks
Provider Selection
Auto Exacto
Private Models
Model Variants
Routers
Features
Workspaces
Workspace Budgets
Switching Workspaces
Single Sign-On (SSO)
SCIM Group Mappings
Presets
Custom Classifiers
Response Caching
Tool Calling
Server Tools
Plugins
Structured Outputs
Message Transforms
Zero Completion Insurance
ZDR
App Attribution
Guardrails
Service Tiers
Sovereign AI
Router Metadata
Input & Output Logging
Broadcast
Ori
Ori Eval
Ori Harness
Where Ori writes files
Privacy
Data Collection
Provider Logging
Best Practices
Latency and Performance
Prompt Caching
Uptime Optimization
Reasoning Tokens
Community
For Providers
Frameworks and Integrations Overview
Awesome OpenRouter
Effect AI SDK
Arize AX
LangChain
LiveKit
Langfuse
Mastra
OpenAI SDK
Anthropic Agent SDK
PydanticAI
Render
Replit
TanStack AI
Vercel AI SDK
Xcode
Zapier
Infisical
On this page
Using the OpenRouter API
Using the Client SDKs
Using the Agent SDK
Using the OpenAI SDK
Using third-party SDKs
Building with an AI assistant
Overview
Quickstart
Copy page
Copy page
Get started with OpenRouter
Copy page
Copy page
OpenRouter gives you access to hundreds of AI models through a single API endpoint. It handles fallbacks automatically and picks the most cost-effective option for each request.
There are three ways to integrate with OpenRouter, depending on how much control you want:
Approach
Best for
API
Full control, any language, no dependencies
Client SDKs
Type-safe model calls with minimal overhead
Agent SDK
Building agents with tool use, loops, and state
Read https://github.com/OpenRouterTeam/skills/tree/main/skills/create-agent-tui and follow the instructions to build an agent using OpenRouter.
Looking for information about free models and rate limits? Please see the
FAQ
In the examples below, the OpenRouter-specific headers are optional. Setting them allows your app to appear on the OpenRouter leaderboards. For detailed information about app attribution, see our
App Attribution guide
.
​
Using the OpenRouter API
The most direct way to use OpenRouter. Send standard HTTP requests to the
/api/v1/chat/completions
endpoint. It works with any language or framework.
You can use the interactive
Request Builder
to generate OpenRouter API requests in the language of your choice.
The examples below use
~openai/gpt-latest
, a
latest alias
that always resolves to the newest OpenAI flagship model, so your code keeps using the freshest version without redeploying. You can substitute any model slug here. Browse the full catalog at
openrouter.ai/models
, or list every available slug programmatically via the
GET /api/v1/models
endpoint.
Python
TypeScript (fetch)
Shell
import
requests
import
json
response
=
requests.post(
url
=
"https://openrouter.ai/api/v1/chat/completions"
,
headers
=
{
"Authorization"
:
"Bearer <OPENROUTER_API_KEY>"
,
"HTTP-Referer"
:
"<YOUR_SITE_URL>"
,
# Optional. Site URL for rankings on openrouter.ai.
"X-OpenRouter-Title"
:
"<YOUR_SITE_NAME>"
,
# Optional. Site title for rankings on openrouter.ai.
},
data
=
json.dumps({
"model"
:
"~openai/gpt-latest"
,
"messages"
: [
{
"role"
:
"user"
,
"content"
:
"What is the meaning of life?"
}
]
})
)
fetch
(
'https://openrouter.ai/api/v1/chat/completions'
, {
method:
'POST'
,
headers:
{
Authorization:
'Bearer <OPENROUTER_API_KEY>'
,
'HTTP-Referer'
:
'<YOUR_SITE_URL>'
,
// Optional. Site URL for rankings on openrouter.ai.
'X-OpenRouter-Title'
:
'<YOUR_SITE_NAME>'
,
// Optional. Site title for rankings on openrouter.ai.
'Content-Type'
:
'application/json'
,
},
body:
JSON
.
stringify
({
model:
'~openai/gpt-latest'
,
messages:
[
{
role:
'user'
,
content:
'What is the meaning of life?'
,
},
],
}),
});
curl
https://openrouter.ai/api/v1/chat/completions
\
-H
"Content-Type: application/json"
\
-H
"Authorization: Bearer
$OPENROUTER_API_KEY
"
\
-d
'{
"model": "~openai/gpt-latest",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'
The API also supports
streaming
. You can also use the
OpenAI SDK
pointed at OpenRouter as a drop-in replacement.
​
Using the Client SDKs
The
Client SDKs
wrap the OpenRouter API with full type safety, auto-generated types from the OpenAPI spec, and zero boilerplate. It’s intentionally lean, a thin layer over the REST API.
First, install the SDK:
npm
pnpm
yarn
bun
deno
pip
npm
install
@openrouter/sdk
pnpm
add
@openrouter/sdk
yarn
add
@openrouter/sdk
bun
add
@openrouter/sdk
deno
add
npm:@openrouter/sdk
pip
install
openrouter
Then use it in your code:
TypeScript
Python
import
{
OpenRouter
}
from
'@openrouter/sdk'
;
const
client
=
new
OpenRouter
({
apiKey:
'<OPENROUTER_API_KEY>'
,
httpReferer:
'<YOUR_SITE_URL>'
,
// Optional. Site URL for rankings on openrouter.ai.
appTitle:
'<YOUR_SITE_NAME>'
,
// Optional. Site title for rankings on openrouter.ai.
});
const
completion
=
await
client
.
chat
.
send
({
model:
'~openai/gpt-latest'
,
messages:
[
{
role:
'user'
,
content:
'What is the meaning of life?'
,
},
],
});
console
.
log
(
completion
.
choices
[
0
].
message
.
content
);
from
openrouter
import
OpenRouter
import
os
with
OpenRouter(
api_key
=
os.getenv(
"OPENROUTER_API_KEY"
))
as
client:
response
=
client.chat.send(
model
=
"~openai/gpt-latest"
,
messages
=
[
{
"role"
:
"user"
,
"content"
:
"What is the meaning of life?"
}
],
)
print
(response.choices[
0
].message.content)
See the full
Client SDKs documentation
for streaming, embeddings, and the complete API reference.
​
Using the Agent SDK
The
Agent SDK
(
@openrouter/agent
) provides higher-level primitives for building AI agents. It handles multi-turn conversation loops, tool execution, and state management automatically via the
callModel
function.
Install the package:
npm
pnpm
yarn
bun
deno
npm
install
@openrouter/agent
pnpm
add
@openrouter/agent
yarn
add
@openrouter/agent
bun
add
@openrouter/agent
deno
add
npm:@openrouter/agent
Build an agent with tools:
import
{
OpenRouter
,
tool
}
from
'@openrouter/agent'
;
import
{
z
}
from
'zod'
;
const
openrouter
=
new
OpenRouter
({
apiKey:
process
.
env
.
OPENROUTER_API_KEY
,
});
const
weatherTool
=
tool
({
name:
'get_weather'
,
description:
'Get the current weather for a location'
,
inputSchema:
z
.
object
({
location:
z
.
string
().
describe
(
'City name'
),
}),
execute
:
async
({
location
})
=>
{
return
{
temperature:
72
,
condition:
'sunny'
,
location
};
},
});
const
result
=
openrouter
.
callModel
({
model:
'~anthropic/claude-sonnet-latest'
,
messages:
[
{
role:
'user'
,
content:
'What is the weather in San Francisco?'
},
],
tools:
[
weatherTool
],
});
const
text
=
await
result
.
getText
();
console
.
log
(
text
);
See all 28 lines
The SDK sends the prompt, receives a tool call from the model, executes
get_weather
, feeds the result back, and returns the final response, all in one
callModel
invocation.
See the full
Agent SDK documentation
for stop conditions, streaming, dynamic parameters, and more.
​
Using the OpenAI SDK
You can also use the OpenAI SDK pointed at OpenRouter as a drop-in replacement. This is useful if you have existing code built on the OpenAI SDK and want to access OpenRouter’s model catalog without changing your code structure.
Typescript
Python
import
OpenAI
from
'openai'
;
const
openai
=
new
OpenAI
({
baseURL:
'https://openrouter.ai/api/v1'
,
apiKey:
'<OPENROUTER_API_KEY>'
,
defaultHeaders:
{
'HTTP-Referer'
:
'<YOUR_SITE_URL>'
,
// Optional. Site URL for rankings on openrouter.ai.
'X-OpenRouter-Title'
:
'<YOUR_SITE_NAME>'
,
// Optional. Site title for rankings on openrouter.ai.
},
});
async
function
main
() {
const
completion
=
await
openai
.
chat
.
completions
.
create
({
model:
'~openai/gpt-latest'
,
messages:
[
{
role:
'user'
,
content:
'What is the meaning of life?'
,
},
],
});
console
.
log
(
completion
.
choices
[
0
].
message
);
}
main
();
See all 26 lines
from
openai
import
OpenAI
client
=
OpenAI(
base_url
=
"https://openrouter.ai/api/v1"
,
api_key
=
"<OPENROUTER_API_KEY>"
,
)
completion
=
client.chat.completions.create(
extra_headers
=
{
"HTTP-Referer"
:
"<YOUR_SITE_URL>"
,
# Optional. Site URL for rankings on openrouter.ai.
"X-OpenRouter-Title"
:
"<YOUR_SITE_NAME>"
,
# Optional. Site title for rankings on openrouter.ai.
},
model
=
"~openai/gpt-latest"
,
messages
=
[
{
"role"
:
"user"
,
"content"
:
"What is the meaning of life?"
}
]
)
print
(completion.choices[
0
].message.content)
​
Using third-party SDKs
For information about using third-party SDKs and frameworks with OpenRouter, please
see our frameworks documentation.
​
Building with an AI assistant
If you write code with an AI coding tool (Claude Code, Cursor, Codex, and others), connect the
OpenRouter MCP server
. It’s a remote server hosted by OpenRouter, so there’s nothing to install. Your assistant can pull live OpenRouter data (which models exist, what they cost, your credit balance, usage rankings) and search these docs while you build. That way its suggestions reflect current data instead of stale training knowledge. Add one URL to your MCP client and approve an OAuth login:
https://mcp.openrouter.ai/mcp
See the
MCP server guide
for per-client setup and the full tool list. To run models in your app, keep calling the OpenRouter API directly.
Batch
⌘
I
Assistant
Responses are generated using AI and may contain mistakes.
