Skip to content

Images Edits

POST https://wrouter.ai/v1/images/edits

Two request shapes are accepted, routed by model:

  • OpenAI shape (multipart/form-data) — dall-e-2, gpt-image-1
  • Bailian / Qwen shape (application/json) — qwen-image-edit; the shape natively documented by the underlying gateway

Shape A: OpenAI (multipart/form-data)

FieldTypeRequiredNotes
modelstringdall-e-2, gpt-image-1
imagefilePNG with alpha, ≤ 4 MB
maskfilePNG; transparent pixels = areas to repaint
promptstringDescription
ninteger
sizestringe.g. 1024x1024
response_formatstring"url" or "b64_json"
bash
curl https://wrouter.ai/v1/images/edits \
  -H "Authorization: Bearer $WROUTER_API_KEY" \
  -F model=gpt-image-1 \
  -F image=@./original.png \
  -F mask=@./mask.png \
  -F prompt="Replace background with a starry sky" \
  -F size=1024x1024
python
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://wrouter.ai/v1")
with open("original.png","rb") as img, open("mask.png","rb") as mask:
    out = client.images.edit(
        model="gpt-image-1",
        image=img,
        mask=mask,
        prompt="Tropical beach background",
        size="1024x1024",
    )
print(out.data[0].url)

Shape B: Bailian / Qwen (application/json)

ParameterTypeRequiredNotes
modelstringqwen-image-edit family
inputobjectprompt, image (URL or base64), optional mask
parametersobjectsize, n, …
bash
curl https://wrouter.ai/v1/images/edits \
  -H "Authorization: Bearer $WROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-edit",
    "input": {
      "prompt": "Replace background with a starry sky",
      "image": "https://example.com/original.png"
    },
    "parameters": {"size": "1024*1024"}
  }'

Mask rules (OpenAI shape)

  • Same dimensions as image
  • Transparent pixels = repaint
  • Opaque pixels = preserve
  • Without mask, the entire image is reinterpreted as reference (model-dependent)