Image Editing

Upload an original image to /v1/images/edits and edit it locally (inpainting, masked modifications) guided by a prompt. For available models and prices see the Model Plaza (look for image model names containing edit); below we use qwen-image-edit-plus.

WARNING

Important distinction — confirm which endpoint you need first:

  • /v1/images/edits: localized image editing, masked inpainting. Requires multipart/form-data; application/json is not supported, and passing an image HTTP URL is not supported — the image must be uploaded as a form file.
  • /v1/images/generations: text-to-image and whole-image redraws. Accepts a JSON body and public image URLs directly. If you want a whole-image redraw / image-to-image without localized masking, use this endpoint — see Text-to-Image & Image-to-Image.

Endpoint

POST /v1/images/edits

Authentication

Pass the Bearer token in the request header:

Authorization: Bearer sk-your-token

Request Body

FieldTypeRequiredNotes
modelstringYesImage editing model name, e.g. qwen-image-edit-plus
imagefileYesOriginal image file — form file upload only, no image URL
promptstringYesDescription of the edit — localized edits or inpainting
sizestringNoOutput image size, e.g. 1024x1024

Request Examples

cURL
Python (openai)
Node.js (openai)
curl https://api-model.shuntianchuang.cn/v1/images/edits \
  -H "Authorization: Bearer sk-your-token" \
  -F model=qwen-image-edit-plus \
  -F image=@origin.webp \
  -F 'prompt=Replace the background with a starry sky, keep everything else unchanged' \
  -F size=1024x1024 \
  -o edited.webp

Response Notes

NOTE

The endpoint is multipart/form-data; JSON bodies are forbidden, the image parameter must be a local file upload, and direct https links are not supported. When debugging in Apifox, switch Body to form-data and set the image field type to File to upload a file.

The response may return binary image content directly instead of JSON (the -o flag in the cURL example saves the image locally) — use the response header Content-Type to tell them apart.

The common error convert_request_failed: image is required indicates a malformed request, usually caused by mistakenly passing an image URL in JSON — switch to a form file upload; for whole-image redraws use /v1/images/generations instead, see Text-to-Image & Image-to-Image.