GPT Image 2
Generate images from text or edit images using references.
POST
/api/v1/generationsExample 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.
| Parameter | Description |
|---|---|
promptstring · Required | Describe the image you want to create. Maximum 20,000 characters. |
image_urlsstring[] · Optional | Public HTTPS reference images. Omit for text-to-image. Up to 16 items. |
aspect_ratiostring · Optional | Requested image proportions.auto1:11:22:12:33:24:33:44:55:416:99:1621:9Default: auto |
resolutionstring · Optional | Output resolution tier. Values are case-sensitive.1k2k4kDefault: 1k |
qualitystring · Optional | Image quality. Affects credit cost.lowmediumhighDefault: medium |
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
| Quality | 1k | 2k | 4k |
|---|---|---|---|
| low | 3 | 5 | 8 |
| medium | 6 | 8 | 10 |
| high | 20 | 25 | 30 |
Credits per image. The example uses 25 credits.
Constraints
4k supports only 1:2, 2:1, 16:9, 9:16 and 21:9.
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