Skip to main content
Qwen

Qwen — OpenAI-compatible image generation

Call the qwen-image-3.0 series for text-to-image and image-to-image/editing through the OpenAI Images-compatible protocol

POST
/compatible-mode/v1/images/generations
curl --location 'https://maas.qwencloudapi.com/compatible-mode/v1/images/generations' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
  "model": "qwen-image-3.0-pro",
  "prompt": "A vertical outdoor portrait photograph with a warm afternoon street atmosphere. Deep green vines and small orange flowers cascade from building eaves across the upper area. A dark blue sign reads '\''Il Messaggero'\'' in white Gothic lettering, partially obscured by foliage. Below, a newsstand displays newspapers behind black metal-framed glass, blurred by shallow depth of field. Strong backlight streams from the street'\''s end. Center-right, a young woman in a black spaghetti-strap backless dress looks back at the camera with a warm smile. Her long, thick wavy black hair is outlined by golden rim light. She has fair skin, bright eyes, soft coral-red lips, and holds a large bouquet of orange, apricot, pink and peach roses contrasting with her black dress. The sunlit city street stretches into the blurred background. Warm film-like tones with fine grain, soft contrast and pronounced backlit edge glow create a romantic, bright, urban strolling atmosphere.",
  "size": "1024x1024",
  "n": 1,
  "prompt_extend": true
}'
{
  "created": 1788339600,
  "data": [
    {
      "url": "https://dashscope-result-sg.oss-ap-southeast-1.aliyuncs.com/xxx.png?Expires=xxx"
    }
  ],
  "usage": {
    "output_height": 1024,
    "output_width": 1024,
    "input_image_count": 0,
    "input_image_type": "qima_input_1k",
    "output_image_count": 1,
    "output_image_type": "qima_output_1k"
  }
}
Image generation can take a while. Set a generous client-side timeout. For multi-image output (larger n) or concurrent calls, start at 600 seconds to avoid the client disconnecting early.

Authorizations

string
header
required

DashScope API key. Get your API key from QwenCloud console.

Body

application/json
enum<string>
required

Model name.

qwen-image-3.0-pro,qwen-image-3.0
qwen-image-3.0-pro
string
required

Positive prompt describing the desired image content, style, and composition. Chinese and English supported, up to ~4500 tokens. Cannot be empty.

A vertical outdoor portrait photograph with a warm afternoon street atmosphere. Deep green vines and small orange flowers cascade from building eaves across the upper area. A dark blue sign reads 'Il Messaggero' in white Gothic lettering, partially obscured by foliage. Below, a newsstand displays newspapers behind black metal-framed glass, blurred by shallow depth of field. Strong backlight streams from the street's end. Center-right, a young woman in a black spaghetti-strap backless dress looks back at the camera with a warm smile. Her long, thick wavy black hair is outlined by golden rim light. She has fair skin, bright eyes, soft coral-red lips, and holds a large bouquet of orange, apricot, pink and peach roses contrasting with her black dress. The sunlit city street stretches into the blurred background. Warm film-like tones with fine grain, soft contrast and pronounced backlit edge glow create a romantic, bright, urban strolling atmosphere.
string

URL or Base64 encoded data of the input image. Omit for T2I; provide for I2I (1-3 images). Pass a string for one image, or an array of strings for multiple (array order defines image order). Do not pass null or an empty array, or a 400 is returned. Formats: JPG/JPEG/PNG/BMP/TIFF/WEBP/GIF; width and height 384-2048 px recommended; size up to 10MB.

Supported input formats:

  1. Public URL: HTTP and HTTPS protocols are supported.
  2. Base64 encoding: Format is data:{MIME_type};base64,{base64_data}.
integer
default1

Number of output images. A string (e.g. "1") returns 400; must be an integer.

1 <= x <= 6
string
default"auto"

Output resolution as widthxheight (letter x separator). auto lets the model recommend. Pixel area 512x512 to 2048x2048, aspect ratio 1:8 to 8:1. Note this differs from the DashScope * separator; adjust when migrating.

1024x1024
string

Negative prompt describing content you do not want in the image.

integer

Random seed. Random when omitted; a fixed seed makes results relatively stable.

0 <= x <= 2147483647
boolean
defaulttrue

Whether to enable intelligent prompt rewriting (recommended). Rewrites the positive prompt per prompt_extend_mode.

enum<string>
default"direct"

Prompt rewriting mode. direct: direct prompt enhancement (DPE), supports both T2I and I2I; agent: agentic prompt enhancement (APE), T2I only; passing it for I2I returns 400.

direct,agent
boolean
defaulttrue

Whether to enable thinking mode. Improves image quality with stronger reasoning but increases latency. Effective only when prompt_extend=true; I2I Agent is not yet supported.

boolean
defaultfalse

Whether to add a watermark.

Response

200-application/json
integer

Unix timestamp (seconds) when the response was created.

object[]

List of generated results. Contains multiple elements when n > 1.

object

Resource usage for this call, returned only on success. This is image input/output metering, not token usage.

object

Error info, returned only on failure. OpenAI-compatible mode does not return request_id in the body; the request id is returned via the x-request-id HTTP header. With the OpenAI Python SDK, read response._request_id on success or APIStatusError.request_id on failure.