Image Generation & Editing API
OpenAI-compatible image generation endpoint. Follow the parameters and examples below.
1. Image Generations
- Path:
/v1/images/generations - Request Method:
POST
Core Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image generation model name, e.g., gpt-image-2.5-flare (OpenAI), doubao-seedream-5-0-flash-260915 (Volcengine), qwen-image-3.0-pro (Alibaba Qwen) |
prompt | string | Yes | Text prompt describing the desired image |
n | integer | No | Number of images to generate (default 1. Note: Volcengine Seedream 5.0 Flash / Pro only support single-image n=1; use seedream-5.0-lite or 4.5 for group images) |
size | string | No | Resolution (e.g., 1024x1024), alternative to resolution |
resolution | string | No | Resolution option (e.g., 1k / 2k), alternative to size |
response_format | string | No | url (default) or b64_json. The gateway adapts to upstream automatically and returns image URLs or Base64 data as requested |
output_format | string | No | Image encoding format, such as png / jpeg / webp |
watermark | boolean | No | Whether to add a watermark |
web_search | boolean | No | Whether to enable web search (default false; effective on Volcengine/Gemini, ignored on Wan) |
ratio | string | No | Aspect ratio option (e.g., 16:9, 3:4; mainly for Gemini and other models supporting aspect ratios) |
image | string / array | No | Reference image URL or array of URLs for image-to-image (OpenAI protocol extension supporting direct web image URLs, single or multiple) |
image_urls | array | No | Array of reference image URLs for image-to-image. Use when specifying multiple reference images; must be an array |
For Alibaba Qwen Image (
qwen-image-3.0-pro), see Qwen Image Generation.
Curl Image Generation Example (Text-to-Image)
curl -X POST https://www.tokenpad.ai/v1/images/generations \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "An astronaut cat floating in space, realistic cyberpunk style",
"size": "1024x1024",
"n": 1
}'
Response Example (Direct Image URL)
{
"created": 1719441600,
"data": [
{
"url": "https://example.com/output/img_abc123.png"
}
]
}
2. Image Edits & Inpainting
- Path:
/v1/images/edits - Request Method:
POST
Supports passing a base image (Image) and a mask (Mask) with a prompt for partial erasure and inpainting. Compatible with the following two parameter formats:
A. Minimal JSON Parameter Format (Direct Web Image URL)
This is an extra gateway extension to simplify development. Instead of dealing with cumbersome multipart file stream uploads, you can pass image web URLs directly in the JSON payload. Request Example:
curl -X POST https://www.tokenpad.ai/v1/images/edits \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"image": "https://example.com/assets/base_image.png",
"mask": "https://example.com/assets/mask_image.png",
"prompt": "Add a red knit beanie to the masked area while keeping lighting and shadows consistent with the background",
"size": "1024x1024",
"n": 1
}'
B. OpenAI Standard Form-Data Format (Upload Local Binary File)
100% compatible with the official OpenAI native specification, suitable for clients uploading local images directly. Request Example:
curl -X POST https://www.tokenpad.ai/v1/images/edits \
-H "Authorization: Bearer sk-your_token" \
-F "model=gpt-image-2.5-flare" \
-F "image=@/path/to/base_image.png" \
-F "mask=@/path/to/mask_image.png" \
-F "prompt=Add a red knit beanie to the masked area while keeping lighting and shadows consistent with the background" \
-F "size=1024x1024" \
-F "n=1"
3. Image-to-Image & Multi-Image Reference Generation
Pass reference images via image or image_urls for image-to-image / multi-image reference (role and type are equivalent):
-
Single-Image Image-to-Image (pass 1 image only): Used as a single reference image for image-to-image generation. Request Example:
{ "model": "gpt-image-2.5-flare", "prompt": "Change the fur color of this cat to golden yellow, realistic style", "image": "https://example.com/assets/cat.png" } -
Multi-Image / Subject Reference Generation (pass multiple images): Used for multi-image / subject reference. Request Example:
{ "model": "gpt-image-2.5-flare", "prompt": "Integrate the character from image 1 into the cyberpunk street scene of image 2", "image_urls": [ "https://example.com/character.png", "https://example.com/background.png" ] } -
Explicit Image Role Declaration (Optional): If you want to specify the exact purpose of each image, pass elements as objects with a
roleor equivalenttypefield: Request Example:{ "model": "gpt-image-2.5-flare", "prompt": "Repaint the scene using the character from image 1 as reference", "image_urls": [ { "url": "https://example.com/character.png", "type": "reference_image" } ] }