Qwen Image Edit API Docs
Use the image editing API from external systems. Supports session auth and Bearer API key auth.
Endpoint
POST /api/qwen-image-edit
Authentication
- Session auth (browser cookie)
- API key (request header): Authorization: Bearer sk-xxxxxxxx
Request Parameters
- instruction / prompt: Editing instruction (max 800 chars)
- model: Optional, defaults to chatgpt-image-2-free; chatgpt-image-2 is accepted as an alias
- imageUrl / imageUrls / imageBase64: At least one image input, max 4 images; per-model limits are listed below
- n: Number of output images; current image edit models return up to 1 image and extra values are clamped
- aspectRatio: Allowed values depend on the model. ChatGPT Image 2 Free supports auto, 1:1, 16:9, 9:16, 4:3, 3:4, and more
- Optional fields: watermark, negative_prompt, size, prompt_extend
Supported Models
| model | Name | Input images | Outputs | aspectRatio | Credits/image |
|---|---|---|---|---|---|
| chatgpt-image-2-free | ChatGPT Image 2 Free | 4 | 1 | auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 5:4, 4:5, 2:1, 1:2, 21:9, 9:21 | 6 |
| gpt-image-2 | GPT Image 2 | 1 | 1 | Provider default | 6 |
| nano-banana-2 | Nano Banana 2 | 4 | 1 | auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:9 | 6 |
| gpt-image-1-5 | GPT Image 1.5 | 1 | 1 | 1:1, 3:2, 2:3 | 6 or 22 |
| seedream-5-0 | Seedream 5.0 | 4 | 1 | auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:9 | 6 |
| qwen-image | Qwen Image | 3 | 1 | 1:1, 16:9, 9:16, 4:3, 3:4 | 6 |
When model is omitted, chatgpt-image-2-free is used. gpt-image-2 and chatgpt-image-2-free route to different upstream providers; chatgpt-image-2-free is recommended for most API users.
cURL: ChatGPT Image 2
curl -X POST "https://your-domain.com/api/qwen-image-edit" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
"model": "chatgpt-image-2-free",
"imageUrls": ["https://your-cdn.com/input.jpg"],
"instruction": "Change the background to snowy mountains and keep the subject unchanged",
"aspectRatio": "1:1",
"n": 1
}'Success Response
{
"data": [
{
"url": "data:image/png;base64,iVBORw0K...",
"index": 0
}
],
"cost": 6,
"warnings": [],
"generation": {
"uuid": "generation-uuid",
"stored_images": ["https://your-storage.com/result.png"]
},
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 2
},
"model": "chatgpt-image-2-free"
}Common Error Codes
- 400: Invalid parameters
- 401: Unauthenticated
- 402: Insufficient credits
- 500: Server error