Back to Models
GPT-4.1
openaiopenai/gpt-4.1
API guide
Chat completion
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-4.1","messages":[{"role":"user","content":"Hello"}]}'Streaming
GPT-4.1 supports server-sent events (SSE) streaming for real-time token output β essential for responsive chat UIs and agentic workflows that need early partial results.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-4.1","messages":[{"role":"user","content":"Hello"}],"stream":true}'Function calling / Tools
GPT-4.1 is explicitly trained for reliable tool calling, with reduced extraneous edits (9% β 2%) β making it ideal for agentic pipelines that invoke APIs, query databases, or orchestrate multi-step workflows.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"openai/gpt-4.1",
"messages":[{"role":"user","content":"What is the weather in Tokyo?"}],
"tools":[{"type":"function","function":{"name":"get_weather","parameters":{"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}}}]
}'Structured output (JSON)
GPT-4.1 supports response_format to constrain output to valid JSON β ideal for data extraction, classification, and downstream pipeline integration where schema compliance matters.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"openai/gpt-4.1",
"messages":[{"role":"user","content":"Extract the name and age from: John is 30"}],
"response_format":{"type":"json_object"}
}'Vision
GPT-4.1 accepts images as input (text + image modalities) β use base64 or URL inline for tasks like document analysis, chart reading, and UI screenshot understanding.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"openai/gpt-4.1",
"messages":[
{"role":"user","content":[
{"type":"text","text":"Describe this chart"},
{"type":"image_url","image_url":{"url":"https://therouter.ai/assets/vision-sample.png"}}
]}
]
}'Fact ledger β every claim on this page traces here
| source | URL | retrieved | |
|---|---|---|---|
| Release date | openai.com β | 2026-05-28 | verified |
| Knowledge cutoff | openai.com β | 2026-05-28 | verified |
| License | openai.com β | 2026-05-28 | verified |
| Max output tokens | openai.com β | 2026-05-28 | verified |
| Deprecates | openai.com β | 2026-05-28 | verified |
| SWE-bench Verified | openai.com β | 2026-05-28 | verified |
| Scale MultiChallenge | openai.com β | 2026-05-28 | verified |
| Video-MME (long, no subtitles) | openai.com β | 2026-05-28 | verified |
| Aider Polyglot (diff) | openai.com β | 2026-05-28 | verified |
| OpenAI launches GPT-4.1 family with 1M context, better coding, lower prices | openai.com β | 2026-05-28 | verified |
| GPT-4.5 Preview deprecation deadline | openai.com β | 2026-05-28 | verified |
| Is GPT-4.1 a reasoning model like o3? | openai.com β | 2026-05-28 | to verify |
| How does GPT-4.1 compare to GPT-4o in coding? | openai.com β | 2026-05-28 | to verify |
| Should I migrate from GPT-4.5 Preview to GPT-4.1? | openai.com β | 2026-05-28 | to verify |