gpt-image-2

by OpenAI

openai/gpt-image-2

Generate an image from a written description.

Billed per
token
Price
Text input / 1M tokensOfficial price: $5.00Sale price: $3.575Text output / 1M tokensPrice: $0Image output / 1M tokensOfficial price: $30.00Sale price: $21.4528.5% off
Provider
OpenAI
Timeout
5 min

Overview

Generate an image from a text prompt. The request may return RUNNING before the image is ready; poll GET /v1/runs/{runId} until COMPLETED. Returns one image. Low and high quality require 1:1 at 1024 × 1024. Medium is the default and retains 1:1, 3:2 and 2:3 framing.

After COMPLETED, decode run.output.data[0].b64_json from base64 to save the image.

Input

These go in the input object of the run request.

FieldTypeRequiredDescription
promptstringYesWhat to draw, in plain language.
Maximum: 32000
aspect_ratiostringNoShape of the image: 1:1; medium also accepts 3:2 or 2:3. Square when omitted.
resolutionstringNoSize class of the image: 1K. 1K when omitted.
qualitystringNoImage quality. All qualities use the canonical GPT Image 2 billing route.
Allowed: low, medium, high
Default: "medium"

Requests up to 1 MB, prompt up to 32,000 characters.

Example

Use your own API key and a saved idempotency key for each new job. Replace image or media placeholders with your own publicly reachable HTTPS URLs. Keep the same key and request body when recovering a timeout.

# Set once per job; reuse this key and the identical body after a timeout.
: "${AGENTSKY_IDEMPOTENCY_KEY:?Set a unique, saved key for this job}"
curl --fail-with-body https://gateway.agentsky.dev/v1/run \
  -H "authorization: Bearer $AGENTSKY_API_KEY" \
  -H "content-type: application/json" \
  -H "Idempotency-Key: $AGENTSKY_IDEMPOTENCY_KEY" \
  -d '{"provider":"openai","endpoint":"gpt-image-2","input":{"prompt":"A paper airplane over a city at dusk, flat illustration"}}'
# If status is READY/RUNNING, poll GET /v1/runs/{runId} with the same API key.

Pricing

28.5% off

Prices per million tokens, using your plan when signed in. Read the final customer charge from price.amount.value after the run finishes. A RUNNING response is not the final bill.

MeterUSD per million tokens
Text inputOfficial price: $5.00Sale price: $3.575
Text outputPrice: $0
Image outputOfficial price: $30.00Sale price: $21.45

Questions