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
sourceURLretrieved
Release dateopenai.com β†—2026-05-28verified
Knowledge cutoffopenai.com β†—2026-05-28verified
Licenseopenai.com β†—2026-05-28verified
Max output tokensopenai.com β†—2026-05-28verified
Deprecatesopenai.com β†—2026-05-28verified
SWE-bench Verifiedopenai.com β†—2026-05-28verified
Scale MultiChallengeopenai.com β†—2026-05-28verified
Video-MME (long, no subtitles)openai.com β†—2026-05-28verified
Aider Polyglot (diff)openai.com β†—2026-05-28verified
OpenAI launches GPT-4.1 family with 1M context, better coding, lower pricesopenai.com β†—2026-05-28verified
GPT-4.5 Preview deprecation deadlineopenai.com β†—2026-05-28verified
Is GPT-4.1 a reasoning model like o3?openai.com β†—2026-05-28to verify
How does GPT-4.1 compare to GPT-4o in coding?openai.com β†—2026-05-28to verify
Should I migrate from GPT-4.5 Preview to GPT-4.1?openai.com β†—2026-05-28to verify
Help & contact