Qwen Image 2.1 Pro Serverless API

Generate transparent PNGs and edit with 10 reference images.

PlaygroundAPI
Pricing
~31.46s
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)

API Endpoint

POSThttps://api.segmind.com/v1/qwen-image-2.1-pro

Parameters

promptrequired
string

Describe the image to generate, or the edit to apply to the reference images. Ask for a transparent background to get an alpha-channel PNG.

imagesoptional
string[]

Optional. Up to 10 images to edit, combine or take style and subject from. Order is preserved.

prompt_extendoptional
boolean

Let 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.

Default: true
prompt_extend_modeoptional
string

How the prompt is rewritten when Prompt Extend is on. Agent is text-to-image only; use Direct when editing.

Default: "direct"
Allowed values :
Direct - light touch-up→"direct"
Agent - fuller rewrite (text-to-image only)→"agent"
seedoptional
integer

Seed for reproducible results.

Range: 0 - 2147483647
sizeoptional
string

Output resolution. All sizes bill the same; total pixels from 512 x 512 up to 2048 x 2048.

Default: "1328*1328"
Allowed values :
1024 x 1024 (square)→"1024*1024"
1328 x 1328 (square, large)→"1328*1328"
768 x 1024 (portrait 3:4)→"768*1024"
1024 x 768 (landscape 4:3)→"1024*768"
1080 x 1440 (portrait 3:4, large)→"1080*1440"
1440 x 1080 (landscape 4:3, large)→"1440*1080"
928 x 1664 (portrait 9:16)→"928*1664"
1664 x 928 (landscape 16:9)→"1664*928"
2048 x 2048 (square, 2K)→"2048*2048"
watermarkoptional
boolean

Add the Qwen watermark to the output.

Default: false

Response 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. 1
    POST /v2/qwen-image-2.1-pro

    Submit — returns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Poll — until COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Result — final response body

Status states

QUEUED— Accepted, waiting for a worker
PROCESSING— Running on a worker
COMPLETED— Done — result body is ready
FAILED— Errored (incl. content/RAI blocks)
  • 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.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out