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.
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.09Btokens
3.
liteLLM
Open-source library to simplify LLM calls
676Mtokens
4.
OpenRouter: Chatroom
Chat with multiple LLMs at once
517Mtokens
5.
MathGPT
Instant homework help from your personal AI math solver
473Mtokens
6.
New API
new
404Mtokens
7.
Xline
new
334Mtokens
8.
BotHub
Multi-model ChatGPT
280Mtokens
9.
Open WebUI
Extensible, self-hosted AI interface
271Mtokens
10.
SillyTavern
LLM frontend for power users
263Mtokens
11.
Kortex
new
257Mtokens
12.
ThrustWorthy - Position Manager
new
208Mtokens
13.
Aider
AI pair programming in your terminal
206Mtokens
14.
RA.Aid
new
178Mtokens
15.
Kilo Code
new
156Mtokens
16.
Infinite Worlds
Build your own adventures, share them with friends
154Mtokens
17.
TypingMind
A better UI for ChatGPT
90.3Mtokens
18.
Chub AI
GenAI for everyone
70.5Mtokens
19.
5050pro.jp
new
62.6Mtokens
20.
LibreChat
Feature-rich, open-source ChatGPT clone
59.7Mtokens
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.