# GPT-4.1

OpenAI designed GPT-4.1 around three priorities: write better code, follow instructions more precisely, and comprehend longer contexts. The result is a model that jumped 21 points on SWE-bench over GPT-4o while costing less to run.

- **Model ID:** `openai/gpt-4.1`
- **Type:** chat
- **Providers:** azure, openai
- **Context window:** 1,047,576
- **Maximum output tokens:** 32,768
- **Pricing:** $2.0/1M input tokens, $8.0/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/gpt-4.1

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { streamText } from 'ai'

const result = streamText({
  model: 'openai/gpt-4.1',
  prompt: 'Why is the sky blue?'
})
```

## About

GPT-4.1 arrived on April 14, 2025 alongside two smaller siblings: GPT-4.1 mini and GPT-4.1 nano. OpenAI built this release around measurable improvements in three areas rather than incremental gains across a broad benchmark suite.

Coding was the centerpiece. GPT-4.1 scored 21.4 points higher than GPT-4o on SWE-bench Verified, the benchmark that measures a model's ability to autonomously resolve real GitHub issues. It also scored 26.6 points above GPT-4.5. For teams building AI-assisted development tools, this translates to better codebase comprehension, more correct patches, and stronger adherence to repository-specific conventions.

Instruction adherence also improved substantially. On Scale AI's MultiChallenge benchmark, GPT-4.1 reached 38.3%, a 10.5-point increase over GPT-4o. This matters for any pipeline where the model must follow a multi-step specification exactly: structured data extraction, form filling, and compliance document processing.

The context window of 1.0M tokens pairs with genuine retrieval accuracy across the full range, not just nominal capacity. OpenAI also restructured pricing: GPT-4.1 costs less than GPT-4o for equivalent queries, the prompt caching discount increased to 75%, and long-context requests no longer carry surcharges. The knowledge cutoff is June 2024.

## What to consider

Agentic coding pipelines that repeatedly send large system prompts or repository context benefit significantly from the 75% prompt caching discount. This is a deeper discount than earlier OpenAI models offered.

## When to use

### Best For

- Autonomous software engineering: code generation, debugging, and refactoring across full repositories using the context window of 1.0M tokens
- Complex multi-step instruction following where precision matters: structured extraction, compliance workflows, and multi-constraint document processing
- Long-document analysis that previously required chunking: legal contracts, research papers, and entire codebases in a single pass
- Multimodal workflows involving video, images, and extended text
- Pipelines with large repeated prompts where the 75% caching discount materially reduces cost

### Consider Alternatives When

- The task is straightforward enough that GPT-4.1 mini or nano can handle it at substantially lower cost
- Mathematical or scientific reasoning dominates; the o-series reasoning models may yield higher accuracy on chain-of-thought workloads
- Ultra-low latency is the primary requirement and capability can be traded for speed

## Best for

- **Autonomous software engineering:** Code generation, debugging, and refactoring across full repositories using the context window of 1.0M tokens
- **Complex instruction following:** Structured extraction, compliance workflows, and multi-constraint document processing where precision matters
- **Long-document analysis:** Legal contracts, research papers, and entire codebases processed in a single pass without chunking
- **Multimodal workflows:** Applications that combine video, images, and extended text in a single request
- **Cache-heavy pipelines:** Large repeated prompts where the 75% caching discount materially reduces cost

## Consider alternatives

- **Simpler tasks:** GPT-4.1 mini or nano can handle straightforward work at substantially lower cost
- **STEM reasoning dominant:** The o-series reasoning models may yield higher accuracy on chain-of-thought workloads
- **Ultra-low latency:** Capability can be traded for speed when response time is the primary requirement

## Frequently asked questions

### How significant is the SWE-bench improvement?

GPT-4.1 improved 21.4 points over GPT-4o and 26.6 points over GPT-4.5 on SWE-bench Verified. This was the largest coding benchmark gain in a single OpenAI model release at the time.

### What does the context window of 1.0M tokens mean in practice?

You can pass an entire large codebase, a full legal document set, or a long multi-session conversation history in a single request. GPT-4.1 retrieves information accurately at all positions within that range.

### How does prompt caching work with GPT-4.1?

Repeated input tokens, such as system prompts or shared context, are cached at a 75% discount off the standard input token price. This is especially valuable for agentic loops that resend the same context on every iteration.

### What is GPT-4.1's knowledge cutoff?

June 2024, updated from GPT-4o's earlier cutoff.

### Does GPT-4.1 handle video input?

Yes. It accepts text, images, and video, and scored 72.0% on Video-MME's long-context, no-subtitles benchmark.

### What are typical latency characteristics?

This page shows live throughput and time-to-first-token metrics measured across real AI Gateway traffic.

## Links

- [Model page](https://vercel.com/ai-gateway/models/gpt-4.1)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/concepts/models-sold-directly-by-azure?pivots=azure-openai&tabs=global-standard-aoai%2Cstandard-chat-completions%2Cglobal-standard#gpt-5.1)
- [Provider pricing](https://platform.openai.com/docs/pricing)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
