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

modelNameInput imagesOutputsaspectRatioCredits/image
chatgpt-image-2-freeChatGPT Image 2 Free41auto, 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:216
gpt-image-2GPT Image 211Provider default6
nano-banana-2Nano Banana 241auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:96
gpt-image-1-5GPT Image 1.5111:1, 3:2, 2:36 or 22
seedream-5-0Seedream 5.041auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 21:96
qwen-imageQwen Image311:1, 16:9, 9:16, 4:3, 3:46

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