GPT Image 2
When calling gpt-image-2 through Qiuqiu Token, use this page to prepare image generation and image editing requests. The model name inside Qiuqiu Token remains gpt-image-2. Complete field definitions, model limits, and the latest enum values are subject to the official OpenAI API documentation.
Before starting, prepare balance in Quick Start, then create a grouped token in Create an API Token. Choose a group whose name includes "CodeX dedicated".
Recommended async image generation URL: https://img.qiuqiutoken.com/.
You can also use the online GPT Image 2 generation website directly: https://image.qiuqiutoken.com/.
Generate Images: POST /v1/images/generations
Official references
This section only lists fields commonly used with Qiuqiu Token. For full fields, enum values, and response structure, use the OpenAI docs:
Minimal request:
curl https://api.qiuqiutoken.com/v1/images/generations \
-H "Authorization: Bearer YOUR_IMAGE_TOKEN_KEY" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"gpt-image-2\",
\"prompt\": \"An orange cat wearing a transparent raincoat on a neon rainy street, cinematic composition\",
\"size\": \"1024x1024\",
\"quality\": \"high\",
\"output_format\": \"png\"
}"Common Fields
| Field | Required | Notes |
|---|---|---|
prompt | Required | Image prompt. Include subject, scene, lighting, composition, and style. |
model | Recommended | Use gpt-image-2 through the Qiuqiu Token gateway. |
size | Optional | Common values include 1024x1024, 1536x1024, 1024x1536, and auto. |
quality | Optional | Common values are low, medium, high, and auto. Higher quality is usually slower and more expensive. |
background | Optional | Common values are transparent, opaque, and auto. Transparent output requires png or webp. |
output_format | Optional | Common values are png, jpeg, and webp. |
output_compression | Optional | Official range is 0 to 100; meaningful only for jpeg or webp. |
n | Optional | Number of images. Official range is 1 to 10. |
moderation | Optional | Common values are low and auto. |
user | Optional | End-user identifier for audit, risk control, or logs. |
Response
For GPT Image models, usually read data[*].b64_json. The most common return value is Base64 image content, not a URL.
{
"created": 1711111111,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
Edit Images: POST /v1/images/edits
Upload the source image, optional mask, and prompt with multipart/form-data. The OpenAI reference describes input images as an images array; with multipart upload, image[]=@... is a common form.
curl https://api.qiuqiutoken.com/v1/images/edits \
-H "Authorization: Bearer YOUR_IMAGE_TOKEN_KEY" \
-F "model=gpt-image-2" \
-F "image[]=@./input.png" \
-F "mask=@./mask.png" \
-F "prompt=Keep the subject pose, change the background to a neon rainy street, and enhance cinematic reflections" \
-F "size=1024x1024" \
-F "quality=high" \
-F "background=transparent" \
-F "input_fidelity=high" \
-F "output_format=png" \
-F "n=1"Common Fields
| Field | Required | Notes |
|---|---|---|
images / image[] | Required | Input images. GPT Image officially supports up to 16 input images. |
prompt | Required | State what to keep, replace, or add. |
model | Recommended | Use gpt-image-2 through the Qiuqiu Token gateway. |
mask | Optional | Transparent areas indicate editable regions. |
size | Optional | Common values include 1024x1024, 1536x1024, 1024x1536, and auto. |
quality | Optional | Common values are low, medium, high, and auto. |
background | Optional | Use png or webp for transparent background. |
input_fidelity | Optional | Common values are low and high. |
output_format | Optional | Common values are png, jpeg, and webp. |
n | Optional | Number of returned images. |
Save the Image
When the response contains b64_json, decode it before saving the image file.
python - <<'PY'
import base64
b64 = "PASTE_B64_JSON_HERE"
with open("gpt-image-output.png", "wb") as f:
f.write(base64.b64decode(b64))
PY
If you use background=transparent, prefer png or webp when saving.
Troubleshooting
- 401 or authentication failure: use
Authorization: Bearerand a valid image group token, notdefault. - 404: confirm the endpoint is
/v1/images/generationsor/v1/images/edits, and the model isgpt-image-2. - Generation parameter error: return to the minimal JSON example, then add fields back one by one.
- Edit file field error: make sure
image[]andmaskare file uploads or officially supported image references, not plain JSON strings. - Result cannot be opened: save decoded binary image data, not the raw Base64 string.
- Transparent background is missing: use
background=transparentandoutput_format=pngorwebp.
