OpenAI: GPT-4.1
openai/gpt-4.1
Created Apr 14, 20251,047,576 context
Starting at $2/M input tokensStarting at $8/M output tokens
Providers for GPT-4.1
OpenRouter routes requests to the best providers that are able to handle your prompt size and parameters, with fallbacks to maximize uptime.
US | Context 1.05M Max Output 33K Input $2 Output $8 |
1.
Cline
Autonomous coding agent right in your IDE
7.55Btokens
2.
Roo Code
A whole dev team of AI agents in your editor
4.15Btokens
3.
liteLLM
Open-source library to simplify LLM calls
580Mtokens
4.
New API
new
523Mtokens
5.
OpenRouter: Chatroom
Chat with multiple LLMs at once
504Mtokens
6.
MathGPT
Instant homework help from your personal AI math solver
454Mtokens
7.
Xline
new
322Mtokens
8.
BotHub
Multi-model ChatGPT
301Mtokens
9.
Kortex
new
297Mtokens
10.
Open WebUI
Extensible, self-hosted AI interface
293Mtokens
11.
SillyTavern
LLM frontend for power users
261Mtokens
12.
ThrustWorthy - Position Manager
new
246Mtokens
13.
Aider
AI pair programming in your terminal
198Mtokens
14.
RA.Aid
new
191Mtokens
15.
Kilo Code
new
178Mtokens
16.
Infinite Worlds
Build your own adventures, share them with friends
160Mtokens
17.
5050pro.jp
new
70.1Mtokens
18.
LibreChat
Feature-rich, open-source ChatGPT clone
68.9Mtokens
19.
Local Operator
AI agents on your device
58.6Mtokens
20.
Chub AI
GenAI for everyone
57.8Mtokens
When an error occurs in an upstream provider, we can recover by routing to another healthy provider, if your request filters allow it.
Learn more about our load balancing and customization options.
Sample code and API for GPT-4.1
OpenRouter normalizes requests and responses across providers for you.
OpenRouter provides an OpenAI-compatible completion API to 300+ models & providers that you can call directly, or using the OpenAI SDK. Additionally, some third-party SDKs are available.
In the examples below, the OpenRouter-specific headers are optional. Setting them allows your app to appear on the OpenRouter leaderboards.
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-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
},
extra_body={},
model="openai/gpt-4.1",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
]
)
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.
See the Request docs for all possible fields, and Parameters for explanations of specific sampling parameters.