APIMart
Back to all models

GPT-4.1 API

OpenAIModel ID gpt-4.1Text modelReleased April 14, 2025

GPT-4.1 will be retired on January 14, 2027, after which API calls will stop working. We recommend migrating to GPT-6 Luna ahead of time.

View GPT-6 Luna

Use GPT-4.1 to follow a long style guide to the letter, edit code in a strict diff format, or answer questions across a 1M-token document set without a reasoning step.

Max input
1,047,576 tokens
Max output
32,768 tokens
Input → output
Text, Image → Text
Knowledge cutoff
June 1, 2024
  • Image input
  • Streaming
  • Cached input pricing
  • OpenAI SDK compatible

GPT-4.1 API use cases

Each use case comes with an illustrative example: source material, a prompt and a hand-written sample answer, not actual model output. Copy the prompt, swap in your own material and try it on GPT-4.1.

Try GPT-4.1 with your own material

Following detailed instructions

Give GPT-4.1 a long style guide or output spec and ask it to rewrite content to match. Check the result against the rules that matter most, such as banned terms and length limits.

Example: Rewrite this notice to our style guide

Material

Style guide (excerpt)
Use sentence case for headings. Write dates as 3 March 2026. Never use “utilize”. Keep the notice under 40 words.
Draft notice
Scheduled Maintenance: On 03/03/2026 we will utilize the night window to upgrade servers. Expect short outages.

PromptRewrite the notice to follow every rule in the style guide. Return only the rewritten text.

Sample answer · written by hand to show the reasoning

Scheduled maintenance: On 3 March 2026 we will use the night window to upgrade our servers. Expect short outages.

About the GPT-4.1 API

  • Smart without a reasoning step

    OpenAI calls GPT-4.1 its smartest non-reasoning model. It excels at instruction following and tool calling, and answers with low latency.

  • Shutdown on January 14, 2027

    OpenAI deprecated GPT-4.1 on October 14, 2026 and recommends GPT-6 Luna as the replacement.

  • 1M context, 32K output

    The context window is 1,047,576 tokens and the maximum output 32,768 tokens, with text and image input. Long-context requests cost the standard per-token rates.

  • GPT-4.1 API key and access

    You don’t need a separate GPT-4.1 API key: one APIMart key works for every model, including GPT-6 Luna. Send gpt-4.1 API requests with the model ID gpt-4.1; GPT-4.1 API pricing is in the table on this page.

GPT-4.1 official benchmark results

Selected results OpenAI published at launch.

  • SWE-bench Verified

    54.6%

    Fixing real issues in code repositories. Ahead of GPT-4o (33.2%) and GPT-4.5 (38.0%).

  • Aider’s polyglot (diff)

    52.9%

    Code edits in diff format across languages. Ahead of GPT-4o (18.2%) and GPT-4.5 (44.9%).

  • IFEval

    87.4%

    Following verifiable instructions such as length and format. Ahead of GPT-4o (81.0%).

  • MultiChallenge

    38.3%

    Following instructions across multi-turn conversations. Ahead of GPT-4o (27.8%).

  • OpenAI-MRCR (2 needle, 128K)

    57.2%

    Finding the right detail in a long conversation. Ahead of GPT-4o (31.9%).

  • MMMU

    74.8%

    Questions about charts, diagrams and maps. Ahead of GPT-4o (68.7%).

How to call the GPT-4.1 API

To call GPT-4.1, you only need an APIMart API key and your existing OpenAI SDK, or send plain HTTP requests.

POST /v1/chat/completions
curl https://api.apimart.ai/v1/chat/completions \
  -H "Authorization: Bearer $APIMART_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4.1",
  "messages": [
    {
      "role": "user",
      "content": "Describe how to design a clear API in three sentences."
    }
  ],
  "stream": false
}'

GPT-4.1 access details

Model IDgpt-4.1
Base URLhttps://api.apimart.ai/v1
Endpoint/chat/completions

Common parameters

model
Required
messages
Required
stream
Optional
max_tokens
Optional
temperature
Optional
All request parameters, response fields and error codes

GPT-4.1 API request parameters

GPT-4.1 uses the general chat endpoint, POST /v1/chat/completions, with a JSON body. model and messages are required; every other parameter is optional.

ParameterTypeRequiredDescription
modelstringYesModel ID. Use gpt-4.1 for this model.
messagesarrayYesConversation messages. Each message has a role (system, user, or assistant) and content. Include earlier messages for multi-turn conversations.
streambooleanNoWhether to stream the output. true returns chunks over SSE, false returns the full response at once. Default: true.
temperaturenumberNoOutput randomness, 0–2. Default: 1.0. Lower values give more deterministic output.
top_pnumberNoNucleus sampling, 0–1. Default: 1.0. Adjust this or temperature, not both.
max_tokensintegerNoMaximum number of tokens to generate for the reply.
frequency_penaltynumberNoFrequency penalty, -2.0 to 2.0. Default: 0. Positive values reduce repeated wording.
presence_penaltynumberNoPresence penalty, -2.0 to 2.0. Default: 0. Positive values encourage new topics.
stopstring | arrayNoUp to 4 stop sequences. Generation stops when any of them appears.
nintegerNoNumber of replies to generate. Default: 1.

Response fields

The response contains the fields below. Token usage is returned in usage, which you can use to check costs.

FieldTypeDescription
idstringUnique identifier for the request.
modelstringThe model that handled the request.
choicesarrayList of replies. Each item contains message (role and content) and finish_reason.
usageobjectToken usage: prompt_tokens, completion_tokens, and total_tokens.

Error codes

Failed requests return an error object with code, message, and type.

StatusTypeMeaning
400invalid_request_errorInvalid request parameters.
401authentication_errorThe API key is invalid or missing.
402payment_requiredInsufficient account balance.
403permission_errorNo permission to access this resource.
429rate_limit_errorToo many requests. Retry later.
500server_errorInternal server error.
502bad_gatewayGateway error. The service is temporarily unavailable.

GPT-4.1 API pricing

The GPT-4.1 API is billed by token usage, and prices depend on your membership tier. Prices below are per million tokens; 1 US dollar = 10 credits.

ItemGoldCurrent pricePlatinumDiamondOfficial priceYou save
Input16Credits~$1.615.2Credits~$1.5214.4Credits~$1.4420Credits~$220%
Cached input4Credits~$0.43.8Credits~$0.383.6Credits~$0.365Credits~$0.520%
Output64Credits~$6.460.8Credits~$6.0857.6Credits~$5.7680Credits~$820%

Prices are for reference only. View full pricing

Why call GPT-4.1 API through APIMart

  • 20% below official pricing

    GPT-4.1 API pricing is billed by token usage. Gold to Diamond member prices are 20%–28% below OpenAI's official prices, and cached input costs just $0.4 per 1M tokens.

    See membership prices
  • One API key for 500+ models

    GPT-4.1, the rest of its family and 500+ models from GPT, Claude, Gemini and more share one API key and one account balance. Switching models is just a change to the model parameter.

  • Change two lines of existing code

    If you already use the OpenAI SDK, point base_url at https://api.apimart.ai/v1 and swap in your APIMart API key. Requests and responses keep the same format.

  • Try it online before you code

    Try GPT-4.1 with your own material in the Playground, no code or setup needed, and integrate once you like the results.

    Open Playground

Which OpenAI model should you choose?

Base prices per 1M tokens (USD). Your GPT-4.1 API key works for every model in the table; just change the model parameter.

Differences between OpenAI models
ComparisonGPT-4.1 CurrentGPT-4oGPT-4o miniGPT-4o-2024-11-20GPT-4.1 minio3GPT-5GPT-5 miniGPT-5 nanoGPT-5 ProGPT-5 SearchGPT-5.1GPT-5.2GPT-5.2 ProGPT-5.3-CodexGPT-5.4GPT-5.4 miniGPT-5.4 nanoGPT-5.4 ProGPT-5.5GPT-5.6 LunaGPT-5.6 SolGPT-5.6 TerraGPT-6 AstraGPT-6 LunaGPT-6 SolGPT-6.1 SolGPT-6.1 TerraGPT-6.2 AstraGPT-6.2 Sol
Best forInstruction following, Deprecated, 1M-token contextText and image input, Function calling and structured outputs, No reasoning step, fast repliesHigh-volume classification and extraction, Text and image input, Low-cost small modelNewest GPT-4o snapshot, Text and image input, No reasoning step, fast repliesFast and low-cost, Deprecated, 1M-token contextDeep reasoning, Visual reasoning, Coding and technical writingCoding and agents, Deprecated, Reasoning effort minimal to highCost-efficient reasoning, Deprecated, 400K contextFastest and cheapest, Deprecated, ClassificationHard reasoning, Deprecated, Responses APIWeb search in Chat Completions, Searches before every answer, Text in, text outCoding and agents, Deprecated, Text and image inputProfessional work, Reasoning up to xhigh, Text and image inputHard reasoning, More compute per request, Responses APIAgentic coding, 400K context, Responses APICoding and professional work, 1.05M context, Text and image inputCoding and subagents, 400K context, Text and image inputClassification and extraction, Cheapest GPT-5.4 model, Text and image inputHard reasoning, More compute per request, Text and image inputCoding and professional work, 1.05M context, Reasoning from none to xhighHigh-volume tasks, Classification, Data extractionComplex professional work, Coding and debugging, Text and image inputBalanced cost, Support and review, Text and image inputComplex coding, Professional work, ResearchStructured summaries, Classification, Data extractionComplex coding, Agentic workflows, Testing and debuggingComplex coding, Professional documents, Business workflowsVisual reasoning, Drawings and screenshots, WritingComplex coding, Long-document analysis, Professional researchEveryday coding, Agentic tasks, Writing
Input typesText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageTextText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, ImageText, Image
Max input1,047,576 tokens128,000 tokens128,000 tokens128,000 tokens1,047,576 tokens200,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens272,000 tokens922,000 tokens272,000 tokens272,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens922,000 tokens
Max output32,768 tokens16,384 tokens16,384 tokens16,384 tokens32,768 tokens100,000 tokens128,000 tokens128,000 tokens128,000 tokens272,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens128,000 tokens
Knowledge cutoffJune 1, 2024October 1, 2023October 1, 2023October 1, 2023June 1, 2024June 1, 2024September 30, 2024May 31, 2024May 31, 2024September 30, 2024—September 30, 2024August 31, 2025August 31, 2025August 31, 2025August 31, 2025August 31, 2025August 31, 2025August 31, 2025December 1, 2025February 16, 2026February 16, 2026February 16, 2026April 30, 2026May 18, 2026April 20, 2026April 30, 2026June 1, 2026May 18, 2026June 1, 2026
Input price$1.6$2$0.12$2$0.32$1.6$1$0.2$0.04$12$1$1$1.4$16.8$1.4$2$0.6$0.16$24$4$0.16$3.2$1.6$8$0.08$1.6$1.6$0.8$6.4$1.6
Output price$6.4$8$0.48$8$1.28$6.4$8$1.6$0.32$96$8$8$11.2$134.4$11.2$12$3.6$1$144$24$0.96$16$9.6$40$0.4$8$8$4$32$8

GPT-4.1 FAQ

Is GPT-4.1 being retired?

Yes. OpenAI deprecated GPT-4.1 (snapshot gpt-4.1-2025-04-14) on October 14, 2026, with a shutdown date of January 14, 2027. The recommended replacement is GPT-6 Luna.

How do I migrate from GPT-4.1 to GPT-6 Luna?

Change the model parameter in your gpt-4.1 API requests to gpt-6-luna; the APIMart API key and endpoint stay the same. Re-run a sample of your real requests and compare quality, latency and cost before switching all traffic.

Does GPT-4.1 reason before it answers?

No. OpenAI describes GPT-4.1 as a non-reasoning model: it answers directly, without a reasoning step, which keeps latency low. For multi-step problems that need careful reasoning, a GPT-5 or GPT-6 model is usually the better choice.

Does GPT-4.1 support prompt caching?

Yes. When requests repeat the same prompt prefix, such as a long system prompt or document, the cached part is billed at a 75% discount on the input price, according to OpenAI’s launch post. Put the fixed content first and the changing question last so the prefix can be reused.

What is the difference between GPT-4.1 and GPT-4.1 mini?

GPT-4.1 mini is the smaller, faster version at a lower price, with the same 1,047,576-token context window and 32,768-token output limit. GPT-4.1 scores higher on coding and instruction following, for example 54.6% vs. 23.6% on SWE-bench Verified. Both are deprecated with the same shutdown date.

How can I try this model online?

Click Start chatting or Open Playground to visit the existing APIMart Playground. Select GPT-4.1 in the text category to start exploring.

Which model ID does the GPT-4.1 API use?

Set model to gpt-4.1. Copy the exact ID from the page heading or the integration details panel.

Is it compatible with the OpenAI SDK?

You can keep the OpenAI SDK. Set base_url to https://api.apimart.ai/v1, provide your APIMart API key, and use the model ID on this page.

What is the context window of GPT-4.1?

On APIMart, GPT-4.1 accepts up to 1,047,576 input tokens per request. Your prompt, earlier messages, and file content all count toward it.

How many tokens can it output at once?

GPT-4.1 can output up to 32,768 tokens in a single reply. Use the max_tokens parameter to set a lower limit.

How much does the GPT-4.1 API cost?

The GPT-4.1 API on APIMart is billed by token, and prices depend on your membership tier. Gold: $1.6 per million input tokens and $6.4 per million output tokens. Diamond: $1.44 per million input tokens and $5.76 per million output tokens. Prices may change; the pricing page has the current rates.

Does it support streaming?

Yes. The general chat endpoint streams over SSE by default. Set stream to false to receive the complete response at once.

How do I get an API key?

Sign in to APIMart and create a key on the API Keys page, then send it in the Authorization: Bearer header. The same key also works for other models on the platform.