Skip to content

OpenAI Images API

Generate and edit images through the Qiuqiu Token OpenAI-compatible image API.

Use the OpenAI-compatible image generation and image editing endpoints when calling gpt-image-2 through Qiuqiu Token. Before sending requests, complete the account, balance, and API token setup in Quick Start. Choose a Visual token group that supports gpt-image-2, and do not leave the token in default.

For complete field definitions, available values, and response structures, see:

The generation endpoint uses a JSON request body.

bash
curl https://api.qiuqiutoken.net/v1/images/generations \
-H "Authorization: Bearer sk-your-token" \
-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"
}'
Field Required Notes
prompt Required Image prompt. Include the 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. The official range is 1 to 10.
moderation Optional GPT Image moderation level. Common values are low and auto.
user Optional End-user identifier for audit, risk control, or log correlation.

GPT Image models usually return Base64 image content instead of a directly accessible image URL. Read data[*].b64_json:

{
"created": 1711111111,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}

The editing endpoint uses multipart/form-data to upload the source image, an optional mask, and the text prompt. The OpenAI reference describes input images as an images array; with multipart upload, image[]=@... is a common form.

bash
curl https://api.qiuqiutoken.net/v1/images/edits \
-H "Authorization: Bearer sk-your-token" \
-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"
Field Required Notes
images / image[] Required Input images to edit. GPT Image officially supports up to 16 input images; with multipart upload, image[]=@./input.png is common.
prompt Required Describe what to keep, replace, or add.
model Recommended Use gpt-image-2 through the Qiuqiu Token gateway.
mask Optional Provide a mask as a file upload or another officially supported image reference. 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 Common values are transparent, opaque, and auto. Transparent output requires png or webp.
input_fidelity Optional Controls how strongly source-image details are preserved. Common values are low and high.
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 returned images. The official range is 1 to 10.
moderation Optional GPT Image moderation level. Common values are low and auto.
user Optional End-user identifier for audit, risk control, or log correlation.

After receiving b64_json, decode it before writing the image file.

python
import base64

b64 = "paste data[*].b64_json here"
with open("gpt-image-output.png", "wb") as f:
  f.write(base64.b64decode(b64))

If the request uses background=transparent, prefer png or webp when saving; otherwise transparency may be lost.