Skip to main content
openai avatar

GPT Image 2 API

openai/gpt-image-2

Generate images from a text prompt, with precise instruction-following (counts, layout, multi-part requests) and accurate, legible text rendered inside the image.

0.145

Model Input

Input

The text prompt describing the image to generate. Put any words you want rendered inside the image in quotes.

The size of the generated image. Either a named preset (square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9) or a custom {"width", "height"} object in pixels.

Additional Settings

Customize your input with more control.

Min: 1 - Max: 4

The number of images to generate. Each generated image is billed.

The format of the generated image.

You need to be logged in to run this model and view results.
Log in

Model Output

Output

Generated image output
Generated in 168.104 seconds
Logs (1 lines)

Model Example Requests

Examples

Example output 1Example output 2Example output 3

GPT Image 2 API

GPT Image 2 is a text-to-image AI model by openai. On ModelRunner it runs through a REST API or via MCP from any AI assistant, at $0.145 per image.

POST https://queue.modelrunner.run/openai/gpt-image-2

cURL

# Submit a request to the queue. Input fields go at the top level of the
# body. The optional reserved "metadata" object holds your own flat string
# tags — stored on the request, never sent to the model; filter later with
# GET https://queue.modelrunner.run/requests?metadata=<url-encoded JSON>.
curl -X POST https://queue.modelrunner.run/openai/gpt-image-2 \
  -H "Authorization: Key $MRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a calm mountain lake at sunrise",
    "image_size": "landscape_4_3",
    "num_images": 1,
    "output_format": "png",
    "metadata": {
      "project": "my-project"
    }
  }'
# → { "request_id": "...", "status_url": "...", "response_url": "..." }

# Poll status_url until "COMPLETED", then fetch the result
curl "https://queue.modelrunner.run/openai/gpt-image-2/requests/$REQUEST_ID/status" \
  -H "Authorization: Key $MRUN_API_KEY"
curl "https://queue.modelrunner.run/openai/gpt-image-2/requests/$REQUEST_ID" \
  -H "Authorization: Key $MRUN_API_KEY"

JavaScript

import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("openai/gpt-image-2", {
  input: {
    "prompt": "a calm mountain lake at sunrise",
    "image_size": "landscape_4_3",
    "num_images": 1,
    "output_format": "png"
  },
});
console.log(result);

Python

import os
import requests

headers = {"Authorization": f"Key {os.environ['MRUN_API_KEY']}"}

submitted = requests.post(
    "https://queue.modelrunner.run/openai/gpt-image-2",
    headers=headers,
    json={
      "prompt": "a calm mountain lake at sunrise",
      "image_size": "landscape_4_3",
      "num_images": 1,
      "output_format": "png"
    },
).json()

# Poll submitted["status_url"] until "COMPLETED", then:
result = requests.get(submitted["response_url"], headers=headers).json()

Input parameters

NameTypeRequiredDescription
promptstringyesThe text prompt describing the image to generate. Put any words you want rendered inside the image in quotes.
image_sizeenumnoThe size of the generated image. Either a named preset (square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9) or a custom {"width", "height"} object in pixels. Default: "landscape_4_3".
num_imagesintegernoThe number of images to generate. Each generated image is billed. Default: 1.
output_formatenumnoThe format of the generated image. Default: "png".

Machine-readable: OpenAPI schema · llms.txt

Use GPT Image 2 from Claude & Cursor (MCP)

Point Claude Code, Claude Desktop, Cursor, or any MCP client at the ModelRunner MCP server and GPT Image 2 becomes a tool your assistant can call directly — it authorizes via OAuth (no API key in config) and runs this model with the run_model tool using the endpoint openai/gpt-image-2.

MCP client config (Claude Desktop, Cursor)

{
  "mcpServers": {
    "modelrunner": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.modelrunner.run/mcp"]
    }
  }
}

Claude Code

claude mcp add --transport http modelrunner https://mcp.modelrunner.run/mcp

Then ask your assistant, for example: “Run openai/gpt-image-2 on ModelRunner to generate image”. MCP setup guide.

Model Details

Model Details

GPT Image 2 turns a text prompt into a high-quality image, and its two standout strengths are precise instruction-following and accurate in-image text. It reliably honors counts, spatial relationships, styles, and multi-part requests in a single prompt, and it renders legible, correctly spelled words directly inside the image — something most image models still struggle with. Describe a poster, a product label, a UI mockup, an infographic, or a scene with real words on a sign, and it places the text cleanly and keeps the composition on-prompt.

## Best for - Posters, flyers, and greeting cards where the headline text must read correctly - Product labels, packaging, and signage with brand names or short copy - UI mockups and app screens that need real, legible interface text - Infographics and slides combining layout, labels, and data callouts - Multi-constraint scenes ("three red apples on a wooden table, logo top-left")

## Choose another model when - You want to edit or transform an existing image rather than generate from a prompt — use an image-to-image / image-editing model - You need video instead of a still image — use a video model - You want to drive generation from reference images; this variant generates from text only, with no image input

## Tips - Put the exact words you want rendered in quotes in the prompt, e.g. `the headline "VISIT JAPAN"` — quoting tells the model what to spell verbatim - Be specific about layout, color, and style: state where elements sit ("logo top-left"), the palette, and the visual treatment - Combine constraints in one prompt — counts, positions, and styles are honored together - Use `num_images` (up to 4) to get several variations of the same prompt in one call

## Image size The `image_size` field accepts either a named preset or an exact pixel size. Presets set the aspect ratio and framing: `square_hd` or `square` (1:1), `portrait_4_3` or `portrait_16_9` (taller than wide), or `landscape_4_3` (default) or `landscape_16_9` (wider than tall). For a custom size, pass an object instead — `image_size: { "width": <px>, "height": <px> }` (up to 14142 px per side), e.g. `{ "width": 1280, "height": 720 }`. Match the orientation, or the exact dimensions, to where the image will be used.

## Limitations - Long, dense paragraphs of in-image text can still show occasional spelling slips - Tiny or heavily stylized text may lose legibility - Extremely complex multi-object scenes can drift from the prompt in fine details

To run via the ModelRunner JavaScript client: ```js import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("openai/gpt-image-2", { input: { prompt: 'a vintage travel poster of Kyoto with the headline "VISIT JAPAN"', image_size: "landscape_4_3", num_images: 1, output_format: "png", }, }); ```