Qwen Image 2.1 Pro Serverless API
Generate transparent PNGs and edit with 10 reference images.
POST /v2/qwen-image-2.1-pro · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "qwen-image-2.1-pro",
9 prompt="A die-cut glossy vinyl sticker of a potted monstera deliciosa houseplant in a terracotta pot, bold clean white sticker border, flat illustration, on a fully transparent background with a real alpha channel, no background fill.",
10 size="1328*1328",
11 prompt_extend=False,
12 prompt_extend_mode="direct",
13 seed=12345,
14 watermark=False,
15)
16print(result["status"]) # COMPLETED
17print(result.get("output")) # model output (e.g. media URL)
18print(result["metrics"]["inference_time"]) # server compute seconds
19
20# --- Or submit + poll manually (track request_id, control the cadence) ---
21from segmind import SegmindClient, InferenceFailed, InferenceTimeout
22
23client = SegmindClient() # reads SEGMIND_API_KEY
24payload = {
25 "prompt": "A die-cut glossy vinyl sticker of a potted monstera deliciosa houseplant in a terracotta pot, bold clean white sticker border, flat illustration, on a fully transparent background with a real alpha channel, no background fill.",
26 "size": "1328*1328",
27 "prompt_extend": False,
28 "prompt_extend_mode": "direct",
29 "seed": 12345,
30 "watermark": False,
31}
32job = client.submit_async("qwen-image-2.1-pro", **payload)
33print(job.request_id) # available immediately
34try:
35 result = job.wait(timeout=600, interval=1.0)
36except InferenceTimeout as e:
37 print("still running:", e.request_id)
38except InferenceFailed as e:
39 print("failed:", e.detail) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "qwen-image-2.1-pro",
9 prompt="A die-cut glossy vinyl sticker of a potted monstera deliciosa houseplant in a terracotta pot, bold clean white sticker border, flat illustration, on a fully transparent background with a real alpha channel, no background fill.",
10 size="1328*1328",
11 prompt_extend=False,
12 prompt_extend_mode="direct",
13 seed=12345,
14 watermark=False,
15)
16print(result["status"]) # COMPLETED
17print(result.get("output")) # model output (e.g. media URL)
18print(result["metrics"]["inference_time"]) # server compute seconds
19
20# --- Or submit + poll manually (track request_id, control the cadence) ---
21from segmind import SegmindClient, InferenceFailed, InferenceTimeout
22
23client = SegmindClient() # reads SEGMIND_API_KEY
24payload = {
25 "prompt": "A die-cut glossy vinyl sticker of a potted monstera deliciosa houseplant in a terracotta pot, bold clean white sticker border, flat illustration, on a fully transparent background with a real alpha channel, no background fill.",
26 "size": "1328*1328",
27 "prompt_extend": False,
28 "prompt_extend_mode": "direct",
29 "seed": 12345,
30 "watermark": False,
31}
32job = client.submit_async("qwen-image-2.1-pro", **payload)
33print(job.request_id) # available immediately
34try:
35 result = job.wait(timeout=600, interval=1.0)
36except InferenceTimeout as e:
37 print("still running:", e.request_id)
38except InferenceFailed as e:
39 print("failed:", e.detail)API Endpoint
https://api.segmind.com/v1/qwen-image-2.1-proParameters
promptrequiredstringDescribe the image to generate, or the edit to apply to the reference images. Ask for a transparent background to get an alpha-channel PNG.
imagesoptionalstring[]Optional. Up to 10 images to edit, combine or take style and subject from. Order is preserved.
prompt_extendoptionalbooleanLet the model automatically rewrite and enrich short prompts. Turn off for transparent-background prompts: when on, the model paints a checkerboard instead of a real alpha channel.
trueprompt_extend_modeoptionalstringHow the prompt is rewritten when Prompt Extend is on. Agent is text-to-image only; use Direct when editing.
"direct""direct""agent"seedoptionalintegerSeed for reproducible results.
sizeoptionalstringOutput resolution. All sizes bill the same; total pixels from 512 x 512 up to 2048 x 2048.
"1328*1328""1024*1024""1328*1328""768*1024""1024*768""1080*1440""1440*1080""928*1664""1664*928""2048*2048"watermarkoptionalbooleanAdd the Qwen watermark to the output.
falseResponse Type
Returns: Text/JSON
Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/qwen-image-2.1-proSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out