# GPT Image 2

OpenAI's state-of-the-art image generation and editing model. GPT Image 2 supports flexible image sizes and high-fidelity image inputs for both creation and editing tasks.

- **Model ID:** `openai/gpt-image-2`
- **Type:** image
- **Providers:** openai
- **Context window:** Not applicable
- **Maximum output tokens:** 0
- **Pricing:** $5/1M input tokens, $30/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/gpt-image-2

## Supported parameters

- **Parameters:** `aspectRatio`, `n`
- **Operations:** `text-to-image`, `image-to-image`, `inpainting`
- **Input modalities:** `text`, `image`
- **Output modalities:** `image`
- **Aspect ratios:** `1:3`, `1:1`, `3:1`
- **Resolutions:** Not reported
- **Durations:** Not reported
- **Frame rates:** Not reported
- **Maximum outputs per request:** 10
- **Maximum input images:** Not reported
- **Input image formats:** `png`, `jpeg`, `webp`, `gif`
- **Maximum input image size:** 50 MB

## Example

```ts
import { experimental_generateImage as generateImage } from 'ai';

const result = await generateImage({
  model: 'openai/gpt-image-2',
  prompt: 'A red balloon on a wooden table.'
});
```

## About

GPT Image 2 was released on April 21, 2026 on AI Gateway as OpenAI's state-of-the-art image generation model. It's built for fast, high-quality image generation and editing, with flexible image sizes and high-fidelity image inputs that make it practical for both creation and editing workflows.

Flexible sizing means you can request output dimensions that match the surface you're rendering into (square avatars, wide hero images, tall mobile assets) without forcing the model into a fixed canvas. High-fidelity image inputs let you pass detailed source images for editing tasks while preserving the structure and detail of the original.

Integrate GPT Image 2 through `generateImage` from the AI SDK. Pricing on this page is per generated image, with rates varying by output size and quality settings; check the pricing panel for current values across the dimensions you plan to use.

## What to consider

GPT Image 2 is a generation-focused model, not a language model. It produces images from text and image inputs rather than text from text. Pricing is per generated image and depends on output dimensions and quality.

Call GPT Image 2 with `generateImage` from the AI SDK. Reference the live pricing panel on this page for the current per-image cost across sizes and quality settings.

## When to use

### Best For

- **Fast image generation:** Creating images from text prompts when speed matters alongside fidelity
- **High-fidelity image editing:** Editing existing images while preserving detail from high-resolution inputs
- **Flexible-size outputs:** Generating images at the dimensions an application actually needs without forced cropping
- **Product and marketing visuals:** Promotional imagery, hero shots, and product compositions from detailed prompts
- **Creative tooling:** Building generation and editing features into design and content applications

### Consider Alternatives When

- **Cost-sensitive batch generation:** gpt-image-1-mini for high-volume pipelines where per-image cost dominates
- **Earlier-generation needs:** gpt-image-1 or gpt-image-1.5 if you already depend on their specific output characteristics
- **Image understanding:** A GPT chat model with vision when you need to analyze images rather than generate them
- **Text tasks:** Any GPT chat or reasoning model for non-image workloads like analysis, coding, or generation

## Best for

- **Fast image generation:** Creating images from text prompts when speed matters alongside fidelity
- **High-fidelity image editing:** Editing existing images while preserving detail from high-resolution inputs
- **Flexible-size outputs:** Generating images at the dimensions an application actually needs without forced cropping
- **Product and marketing visuals:** Promotional imagery, hero shots, and product compositions from detailed prompts
- **Creative tooling:** Building generation and editing features into design and content applications

## Consider alternatives

- **Cost-sensitive batch generation:** gpt-image-1-mini for high-volume pipelines where per-image cost dominates
- **Earlier-generation needs:** gpt-image-1 or gpt-image-1.5 if you already depend on their specific output characteristics
- **Image understanding:** A GPT chat model with vision when you need to analyze images rather than generate them
- **Text tasks:** Any GPT chat or reasoning model for non-image workloads like analysis, coding, or generation

## Frequently asked questions

### What can GPT Image 2 generate?

It creates and edits images from text and image inputs, supporting flexible output sizes and high-fidelity image inputs for editing workflows.

### How do I call GPT Image 2 from my application?

Use `generateImage` from the AI SDK. AI Gateway routes the request to GPT Image 2 and returns the generated image.

### Can GPT Image 2 edit existing images?

Yes. It accepts high-fidelity image inputs and produces edited outputs while preserving detail from the source image.

### How is GPT Image 2 priced?

Pricing is per generated image, with rates depending on output size and quality settings. Check the pricing panel on this page for current values across the dimensions you plan to use.

### What output sizes does GPT Image 2 support?

GPT Image 2 supports flexible image sizes. Request the dimensions that match the surface you're rendering into, rather than forcing the model into a fixed canvas.

### Does GPT Image 2 support zero data retention through AI Gateway?

Zero Data Retention is not currently available for this model. Zero Data Retention is offered on a per-provider basis. See https://vercel.com/docs/ai-gateway/capabilities/zdr for details.

### How does AI Gateway handle authentication for GPT Image 2?

AI Gateway accepts a single API key or OIDC token for all requests. You don't embed OpenAI credentials in your application; AI Gateway routes and authenticates on your behalf.

### What are typical generation times?

This page shows live performance metrics measured across real AI Gateway traffic.

## Links

- [Model page](https://vercel.com/ai-gateway/models/gpt-image-2)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://developers.openai.com/api/docs/models/gpt-image-2)
- [Provider pricing](https://developers.openai.com/api/docs/pricing)
