API

Manage your API access and requests.

GPT Image 2 · Documentation
Docs Models

GPT Image 2

Generate images from text or edit images using references.

POST
/api/v1/generations

Example request

Set your FLUX_API_KEY before running. See the parameters below for supported settings.

cURL
curl https://api.flux-context.org/api/v1/generations \
  -H "Authorization: Bearer $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "gpt-image-2",
  "input": {
    "prompt": "Editorial fashion portrait in natural light",
    "aspect_ratio": "4:5",
    "resolution": "2k",
    "quality": "high"
  }
}'

Parameters

Set model to gpt-image-2. These fields belong inside input.

ParameterDescription
prompt
string · Required
Describe the image you want to create. Maximum 20,000 characters.
image_urls
string[] · Optional
Public HTTPS reference images. Omit for text-to-image. Up to 16 items.
aspect_ratio
string · Optional
Requested image proportions.
auto1:11:22:12:33:24:33:44:55:416:99:1621:9
Default: auto
resolution
string · Optional
Output resolution tier. Values are case-sensitive.
1k2k4k
Default: 1k
quality
string · Optional
Image quality. Affects credit cost.
lowmediumhigh
Default: medium
size
string · Optional
Auto resolves 2K to explicit pixels (square when aspect_ratio is auto). Accepts supported ratios or WIDTHxHEIGHT; overrides aspect_ratio.
Default: auto

Reference media

Use your own publicly accessible HTTPS media URLs. Links must remain valid throughout queueing and generation. Base64 and file upload bodies are not supported by this endpoint.

Image-to-image

cURL
curl https://api.flux-context.org/api/v1/generations \
  -H "Authorization: Bearer $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "gpt-image-2",
  "input": {
    "prompt": "Editorial fashion portrait in natural light",
    "aspect_ratio": "4:5",
    "resolution": "2k",
    "quality": "high",
    "image_urls": [
      "https://example.com/front.jpg",
      "https://example.com/back.jpg"
    ]
  }
}'

Credits

Quality1k2k4k
low358
medium6810
high202530

Credits per image. The example uses 25 credits.

Constraints

Custom size requires 2k/4k, multiples of 16, edges <=3840, 655360–8294400 pixels, ratio <=3:1. 4k requires a 3840 edge; incompatible sizes are rejected.

Use returned dimensions when available.

Response

A successful submission returns HTTP 202 and a request ID. Response excerpt:

JSON
{
  "id": "REQUEST_ID",
  "model": "gpt-image-2",
  "status": "processing"
}
Continue readingPoll & download