Images Edits
POST https://wrouter.ai/v1/images/editsTwo 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)
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | ✓ | dall-e-2, gpt-image-1 |
image | file | ✓ | PNG with alpha, ≤ 4 MB |
mask | file | PNG; transparent pixels = areas to repaint | |
prompt | string | ✓ | Description |
n | integer | ||
size | string | e.g. 1024x1024 | |
response_format | string | "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=1024x1024python
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)
| Parameter | Type | Required | Notes |
|---|---|---|---|
model | string | ✓ | qwen-image-edit family |
input | object | ✓ | prompt, image (URL or base64), optional mask |
parameters | object | size, 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)