qwen-image-2
Alibaba Qwen Image 2 on reAPI — async unified text-to-image and image editing with strong in-image text rendering, up to 2K, on one OpenAI-compatible endpoint.
Alibaba's Qwen Image 2 on reAPI — one async endpoint for generation and
editing. Write a prompt for text-to-image, or attach one source image
to edit it in plain language. Known for structured in-image text
(posters, slides, infographics, comics). Submit returns a task_id; poll
until ready. See current 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",
"prompt": "a vintage travel poster that reads VISIT MARS in bold retro type",
"image_size": "16:9"
}'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",
"prompt": "a vintage travel poster that reads VISIT MARS in bold retro type",
"image_size": "16:9",
},
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",
prompt: "a vintage travel poster that reads VISIT MARS in bold retro type",
image_size: "16:9",
}),
});
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",
"prompt": "a vintage travel poster that reads VISIT MARS in bold retro type",
"image_size": "16:9",
})
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))
}Submit response
{
"id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
"model": "qwen-image-2",
"status": "processing",
"created_at": 1735000000
}Poll GET /api/v1/tasks/{id} (see the Tasks reference) until
status === "completed". The completed payload's output.image_urls holds the
generated image URL.
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; the task
endpoint returns the same envelope until completion. Polling does not consume
credits.
Modes
There is no mode field — the modality is implicit in the request shape:
- Text-to-image — no
image_url.promptis required. - Image editing — pass a single
image_url.promptdescribes the change (background swap, object edit, restyle, in-frame text rewrite).
Each request produces exactly one image — there is no n parameter.
Request body
model — string, required
Must be qwen-image-2.
prompt — string, required
Up to 800 characters. Required for both text-to-image and editing.
image_url — string, optional
A single source image for editing. Public HTTPS URL only — base64 / data:
URIs are rejected at the gateway. Passing it switches the request to editing
mode; omit it for text-to-image.
image_size — string, optional, default 16:9
Output aspect ratio.
- Text-to-image accepts:
1:1,3:4,4:3,9:16,16:9. - Editing additionally accepts:
2:3,3:2,21:9.
2:3, 3:2, and 21:9 are editing-only. Requesting one without an
image_url (text-to-image) is rejected with 400.
output_format — string, optional, default png
One of png or jpeg.
seed — integer, optional
The same seed with the same prompt yields a repeatable result.
nsfw_checker — boolean, optional, default false
Enables upstream content moderation. Off by default.
Pricing
Qwen Image 2 bills a flat rate per generated image, independent of modality, resolution, and aspect ratio. Each request produces one image:
credits = ceil(per_image_usd × 1000)where 1 credit = $0.001 USD. Failed and rejected requests are not charged.
The exact per-image credit cost surfaces on the model page and through the playground estimator before submit.
Response
The poll envelope returns the image URL in output.image_urls:
{
"id": "task_019dfd44b7fd74168541552a3260a623",
"model": "qwen-image-2",
"status": "completed",
"output": {
"image_urls": [
"https://cdn.reapi.ai/...png"
]
}
}Generated URLs expire — mirror them to your own storage if you need long-term retention.
Errors
Failures return the standard reAPI envelope { error: { code, message, request_id } }. Common cases:
- Invalid input (prompt over 800 characters, an editing-only
image_sizein text-to-image, a non-HTTPSimage_url) →400. - Insufficient credits →
402. - Rate limited →
429.
See the full catalog at /docs/api/errors.
Tips
- The modality is decided by your inputs, not a flag — omit
image_urlfor generation, include it to edit. - Put the literal text you want rendered in the prompt — Qwen Image 2 is tuned for legible in-image typography, so spelling out headline copy works.
- For wide layouts,
21:9is available only when editing (pass animage_url). - To produce a set of images, send multiple requests — each is billed as one image.