GPT Image 2

Generate and edit images with an Official Group API key, billed per token.

Official Group · model: gpt-image-2 · Token billing

This page covers API keys created in the Official Group. The key selects the group, so keep the public model ID gpt-image-2 in every request and do not add a group field.

At a glance

ItemOfficial Group behavior
API keyMust belong to the Official Group
Public model IDgpt-image-2
SubmissionAsynchronous, returns 202 Accepted
Billed onThe token usage returned with the completed task
PricingOfficial Group token rates on the model list

Generate an image

APIPOOL_ENDPOINT="https://app.apipool.dev"

curl "$APIPOOL_ENDPOINT/v1/images/generations" \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A studio product photo of a blue glass sphere",
    "size": "1:1",
    "resolution": "1k",
    "quality": "low",
    "n": 1
  }'

Edit an uploaded image

Use multipart/form-data for file uploads:

curl "$APIPOOL_ENDPOINT/v1/images/edits" \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=Change the object to emerald green" \
  -F "image=@./source.png" \
  -F "size=1:1" \
  -F "resolution=1k" \
  -F "quality=low" \
  -F "n=1"

Request parameters

FieldRequiredValues and meaning
modelYesAlways gpt-image-2
promptYesImage generation or editing instruction
imageFor file editingOne uploaded source image on /v1/images/edits
sizeNoOutput aspect ratio, for example 1:1
resolutionNoOutput resolution: 1k, 2k, or 4k
qualityNoauto, low, medium, or high
nNoNumber of requested images, 1–4; default 1

size sets the aspect ratio only — pick the resolution tier with resolution (1k, 2k, or 4k). The image endpoints reject stream: true.

Submission and polling

The submission returns a task rather than the finished image:

{
  "id": "imgtask_01...",
  "object": "image_generation.task",
  "status": "submitted",
  "model": "gpt-image-2",
  "created_at": 1787068800
}

Poll the task using the same API key:

TASK_ID="imgtask_01..."

curl "$APIPOOL_ENDPOINT/v1/tasks/$TASK_ID" \
  -H "Authorization: Bearer $APIPOOL_API_KEY"

See Asynchronous image tasks for all status values, polling rules, temporary result URLs, and retryable responses.

Completed task and usage

Once the billing data is confirmed, Official Group results include standardized token usage:

{
  "id": "imgtask_01...",
  "object": "image_generation.task",
  "status": "completed",
  "model": "gpt-image-2",
  "created_at": 1787068800,
  "completed_at": 1787068842,
  "data": [
    {
      "url": "https://objects.example/results/0.png?...",
      "expires_at": 1787072442
    }
  ],
  "result_expires_at": 1787155242,
  "usage": {
    "input_tokens": 18,
    "input_tokens_details": {
      "text_tokens": 18,
      "image_tokens": 0
    },
    "output_tokens": 196,
    "output_tokens_details": {
      "image_tokens": 196
    },
    "total_tokens": 214
  }
}

Billing

Prices are locked at submission time, and the task is charged separately on text input, image input, cached input, and image output tokens. The usage returned with the final task is what you can reconcile against. Current rates are shown under the Official Group on the model list; this page does not repeat prices that can change.

To be charged per delivered image instead, use a key from the Discount Group.