qwen-image-2.1
Alibaba Qwen Image 2.1 on reAPI — async text-to-image and image-to-image with native transparent output, up to 10 reference images, mask-based local edits, 1K/2K.
Alibaba's unified Qwen image model on reAPI — one async endpoint for
generation and editing. Qwen Image 2.1 writes native transparent
PNG / WebP output, combines up to 10 reference images into one result,
and edits a single masked region while leaving the rest of the image
untouched. Mode is implicit: no image_urls → text-to-image; image_urls →
image-to-image; image_urls + mask_url → local edit. See pricing on the
model page.
Quick example
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.1",
"prompt": "A cute cartoon dragon sticker, bold outline",
"background": "transparent",
"resolution": "2K"
}'import requests
resp = requests.post(
"https://reapi.ai/api/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "qwen-image-2.1",
"prompt": "A cute cartoon dragon sticker, bold outline",
"background": "transparent",
"resolution": "2K",
},
timeout=30,
)
print(resp.json())const r = await fetch("https://reapi.ai/api/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "qwen-image-2.1",
prompt: "A cute cartoon dragon sticker, bold outline",
background: "transparent",
resolution: "2K",
}),
});
console.log(await r.json());package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "qwen-image-2.1",
"prompt": "A cute cartoon dragon sticker, bold outline",
"background": "transparent",
"resolution": "2K",
})
req, _ := http.NewRequest("POST",
"https://reapi.ai/api/v1/images/generations", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}Authentication
Every call needs a Bearer token. Generate keys at reapi.ai/settings/apikeys.
Authorization: Bearer YOUR_API_KEYEndpoint
POST /api/v1/images/generations
GET /api/v1/tasks/{id}Submission is async. The POST returns immediately with a task_id; poll the
task endpoint until it completes. Polling does not consume credits. A 1K image
typically takes seconds; 2K takes noticeably longer, up to a few minutes with
reference images.
Request body
One image per request — there is no n.
| Field | Type | Default | Notes |
|---|---|---|---|
model | string | — | qwen-image-2.1. Required. |
prompt | string | — | 1–5000 characters, any language. Required. With several references, name them by position ("the first image", "the second image"). With mask_url, describe what should appear inside the white area. |
image_urls | string[] | — | 1–10 reference images; setting it switches to image-to-image. The order is the order the prompt refers to. JPEG / PNG / WebP, each up to 30 MB and 25 MP, public HTTP(S) URLs that answer a plain GET. |
mask_url | string | — | Black-and-white inpainting mask — white is changed, black is kept. Switches to local-edit mode — see Local edits. |
aspect_ratio | string | 1:1 / auto | 1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21, plus auto with image_urls. Default is 1:1 for text-to-image and auto (nearest supported ratio of the first reference) for image-to-image. Ignored in local-edit mode. |
resolution | string | 1K | 1K / 2K. 2K has four times the pixels and bills at twice the 1K rate. 4K is not available. |
background | string | opaque | opaque / transparent. transparent returns a real alpha channel — see Transparent output. |
output_format | string | png | png / webp / jpeg. PNG and WebP carry alpha; JPEG cannot be combined with background: "transparent". |
enhance_prompt | boolean | true | Rewrites the prompt into a fuller scene description before generating. Pass false to follow your prompt literally. Ignored in local-edit mode. |
seed | integer | — | Omitted → random. The same seed with the same prompt and parameters reproduces the same image. |
content_filter | boolean | true | Safety checking — see content_filter below. |
Checked before anything is submitted or charged:
aspect_ratio: "auto"needsimage_urlsmask_urlneeds exactly oneimage_urlsentrymask_urlcannot be combined withbackground: "transparent"output_format: "jpeg"cannot be combined withbackground: "transparent"- at most 10
image_urls; every media field is a public HTTP(S) URL
Transparent output
Set background: "transparent" and Qwen Image 2.1 returns a PNG (or WebP)
with a real alpha channel — no separate background-removal step. Describe the
subject only: a prompt that mentions a scene, surface or backdrop may come back
opaque. With a reference image, the same setting edits a transparent layer or
cuts a subject out of an ordinary photo.
{
"model": "qwen-image-2.1",
"prompt": "Extract the sneaker as a clean product cutout",
"image_urls": ["https://example.com/sneaker-on-street.jpg"],
"background": "transparent",
"output_format": "png"
}Local edits with mask_url
Send exactly one reference image and a mask of the same aspect ratio (a mask of
a different size is scaled to it). White marks the area to change, black is
kept; a few pixels of feathering along the edge help the blend. In this mode the
output follows the reference image's shape, so aspect_ratio and
enhance_prompt are ignored.
{
"model": "qwen-image-2.1",
"prompt": "A green velvet armchair",
"image_urls": ["https://example.com/living-room.jpg"],
"mask_url": "https://example.com/living-room-mask.png"
}content_filter — boolean, default true
Screens the request and output. Enabled by default; pass
content_filter: false from an API key to turn it off. Requests from the
playground always run with the filter on. A request the filter rejects fails
and the reserved credits are refunded.
With content_filter: false, the output is stored in an isolated bucket and
its URLs stay valid for 30 days — mirror the files if you need them longer.
Troubleshooting
| Failure | What it means | What to do |
|---|---|---|
| Synchronous 400 on submit | A field breaks one of the rules above (auto ratio without references, mask with two references, transparent JPEG, 4K, 11 references, …) | The error names the field — fix and resubmit; nothing was charged |
| Task fails citing a reference URL | A reference or mask URL did not return the file (4xx from the origin, or the domain does not resolve) | Make sure every URL answers a plain GET without cookies or signed headers; fully refunded |
| Transparent request returns an opaque image | The prompt described a background, scene or surface | Describe only the subject when background is transparent |
| Fine details lost with many references | Each extra reference leaves less detail for the others | Stay within four references when fidelity matters; use a landscape ratio such as 3:2 or 16:9 for group shots |
402 on submit | Not enough credits for the reserve | Top up your balance |
No data: URIs. reAPI rejects base64 inputs platform-wide — every URL
field must be a public HTTP(S) URL. Upload to your own object storage (S3, R2,
OSS, …) and pass the URL.
Response envelope
Submit and poll share the same shape — only status and output fill in over
time.
{
"id": "task_019dfd44b7fd74168541552a3260a623",
"model": "qwen-image-2.1",
"status": "completed",
"created_at": 1758600000,
"output": {
"image_urls": ["https://cdn.reapi.ai/media/tasks/.../0.png"]
},
"error": null
}Poll GET /api/v1/tasks/{id} (see the Tasks reference) until
status === "completed". output.image_urls holds the single generated image.
Generated URLs expire — mirror them to your own storage for long-term use.
Failures return { error: { code, message, request_id } }; the full catalog is
at /docs/api/errors.
Pricing
Qwen Image 2.1 bills per delivered image, at a rate set by resolution:
credits = ceil(per_image_rate[resolution] × 1000) 1 credit = $0.001- Resolution is the only price dimension. 2K costs twice 1K; an omitted
resolutionbills as 1K. - Mode does not change the price. Text-to-image, image-to-image and masked edits cost the same at the same resolution.
- Reference images are free. One or ten references, the price is the same.
- Failed generations are refunded in full.
Live per-image rates are on the model page — that table is generated from the current price, so it is always the authoritative number.