The Qwen Image Generation and Editing model supports both text-to-image (T2I) and image-to-image/image editing (I2I). It can generate images directly from text prompts or edit images based on reference images combined with editing instructions. Supports both the OpenAI-compatible and DashScope protocols.
Model overview
Model | Description | Output image specifications |
|---|---|---|
qwen-image-3.0-pro | Qwen Image Generation and Editing 3.0 model that supports both text-to-image (T2I) and image-to-image/image editing (I2I). | Image resolution:
Image format: PNG |
qwen-image-3.0 | Qwen Image Generation and Editing 3.0 standard model that supports both text-to-image (T2I) and image-to-image/image editing (I2I). Balances quality and speed. | |
qwen-image-2.1-pro | Qwen Image Generation and Editing 2.1 Pro model. Image-to-image/image editing (I2I) supports up to 10 reference images. It can also automatically decide whether to output a standard image or an image with a transparent (alpha) channel based on the prompt description. | |
qwen-image-2.1-turbo | Qwen Image Generation and Editing 2.1 Turbo model. The most balanced and cost-effective model in the Qwen-Image series. Image-to-image/image editing (I2I) supports up to 10 reference images. It can also automatically decide whether to output a standard image or an image with a transparent (alpha) channel based on the prompt description. |
Availability
The model, endpoint URL, and API key must belong to the same region. Cross-region calls fail.
- Select a model: Verify that the model is available in your target region.
- Select a URL: Choose the endpoint URL that matches your model's region. Both HTTP and DashScope SDK URLs are supported.
- Configure an API key: Get an API key for the region, and then configure the API key as an environment variable.
- Install the SDK: To make API calls with the SDK, install the DashScope SDK.
Access methods
Qwen Image Generation and Editing offers three access methods with identical model capabilities. Choose the one that fits your application:
Access method | When to use |
|---|---|
Applications already built on the OpenAI Images protocol or the OpenAI SDK. Switch | |
Recommended. Full feature coverage, including both public URL and Base64 image input. | |
Batch generation, or when you do not want to hold a connection open. Submit a task and poll for results with |
OpenAI-compatible
If your application is already built on the OpenAI Images protocol or the OpenAI SDK, you can call Qwen Image Generation and Editing through the OpenAI-compatible mode without changing your request structure. Text-to-image (T2I) and image-to-image/image editing (I2I) share the same endpoint: omit image for T2I, and provide image for I2I.
image extension field on /images/generations. It does not use the multipart file upload format of the official OpenAI /images/edits endpoint. The following are not yet supported: asynchronous calls, streaming output, partial images, /images/edits, multipart, and mask. Passing response_format=b64_json does not raise an error, but it is ignored and the response still contains image URLs. For asynchronous calls, use DashScope asynchronous.URL
- Singapore
- US (Virginia)
- China (Beijing)
- China (Hong Kong)
- Germany (Frankfurt)
- Japan (Tokyo)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/images/generationsbase_url for SDK calls: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1{WorkspaceId} with your actual workspace ID.
Request parametersHeadersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Request bodyUnlike the DashScope protocol, the OpenAI-compatible mode places all parameters at the top level of the request body. There is noinput or parameters nesting.model string (Required)The model name. Available values: qwen-image-3.0-pro, qwen-image-3.0, qwen-image-2.1-pro, and qwen-image-2.1-turbo.prompt string (Required)The positive prompt that describes the image content, style, and composition you want to generate or edit. Both Chinese and English are supported. Recommended maximum: 4,500 tokens. Cannot be an empty string.image string or array (Optional)The URL or Base64 encoded data of the input image. Omit this parameter for text-to-image (T2I). Provide it for image-to-image (I2I), where the qwen-image-2.1 series supports 1-10 images, and the qwen-image-3.0 series supports 1-3 images. Pass a string for a single image, or an array of strings for multiple images. When multiple images are provided, the order is defined by the array sequence.Note: null and empty arrays are rejected with a 400 error.Image requirements:
integer (Optional)The number of output images. Value range: 1 to 6. Default: 1. Must be an integer. A string value such as "1" returns a 400 error.size string (Optional)The output image resolution in the format widthxheight, for example "1024x1024". You can also pass auto. If not specified, the model automatically recommends a resolution based on the prompt.
string (Optional)The negative prompt that describes content you do not want to appear in the image. Only the qwen-image-3.0 series supports this parameter.seed integer (Optional)The random seed. Value range: [0, 2147483647]. If omitted, the service generates a random seed. Use a fixed seed for reproducible results.prompt_extend boolean (Optional)Whether to enable intelligent prompt rewriting. Default: true (recommended). When enabled, the model optimizes the positive prompt using the method specified by prompt_extend_mode, which significantly improves results for simple descriptions.prompt_extend_mode string (Optional)The prompt rewriting method. Default: direct. Options:
boolean (Optional)Enables thinking mode. The default is true. This enhances model reasoning to improve image quality, but increases generation time. It requires prompt_extend=true. Supported for Direct T2I, Direct I2I, and Agent T2I. Not supported for I2I Agent.watermark boolean (Optional)Whether to add a watermark. Default: false.image, negative_prompt, seed, prompt_extend, prompt_extend_mode, enable_thinking, and watermark are Model Studio extension fields, not official OpenAI parameters. For raw HTTP requests, place them at the top level of the request body. When using an OpenAI SDK, pass them through extra_body. |
Response parameterscreatedintegerThe Unix timestamp, in seconds, when the response was created.data arrayThe list of generated results. When n is greater than 1, the array contains multiple elements.
Properties url stringThe URL of the generated image in PNG format. The link is valid for 24 hours. Download and save the image promptly.objectThe resource usage of this call. Only returned on success. These are image input and output metering fields, not token usage.
Properties
output_width integerThe width of the final output image in pixels.output_height integerThe height of the final output image in pixels.input_image_count integerThe number of input images in the request. Returns 0 for text-to-image (T2I), and the actual count for image-to-image (I2I).input_image_type stringThe input image billing tier. Determined by the output resolution pixel area: qima_input_1k if area ≤ 2,250,000, or qima_input_2k if area > 2,250,000.output_image_count integerThe actual number of output images returned.output_image_type stringThe output image billing tier. Determined by the output resolution pixel area: qima_output_1k if area ≤ 2,250,000, or qima_output_2k if area > 2,250,000.objectThe error details. Only returned for failed requests.
Properties message stringDetailed error message.type stringThe error type, such as invalid_request_error.param stringThe name of the parameter that caused the error, or null when the error cannot be attributed to a specific parameter.code stringError code. See Error codes.Unlike the DashScope protocol, the OpenAI-compatible mode does not return request_id in the response body. The unique request identifier is returned in the x-request-id HTTP response header. With the OpenAI Python SDK, read response._request_id on success and APIStatusError.request_id on failure. Include this identifier when reporting an issue. |
Image URLs are retained for only 24 hours and then automatically purged. Save generated images promptly. |
SDK
Install or upgrade the OpenAI Python SDK first:
DashScope synchronous API (recommended)
HTTP
- Singapore
- US (Virginia)
- China (Beijing)
- China (Hong Kong)
- Germany (Frankfurt)
- Japan (Tokyo)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation{WorkspaceId} with your actual workspace ID.
Request parametersHeadersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Request bodymodelstring (Required)The model name. Available values: qwen-image-3.0-pro, qwen-image-3.0, qwen-image-2.1-pro, and qwen-image-2.1-turbo.input object (Required)The input parameter object, which contains the following fields:
Properties messages array (Required)The request content array. Only single-round conversations are supported, so the array must contain exactly one object with role and content properties.
Properties role string (Required)The role of the message sender. Must be set to user.contentarray (Required)The message content array, with different combinations depending on the use case:
Properties image string (Required for I2I)The URL or Base64 encoded data of the input image. In I2I scenarios, the qwen-image-2.1 series supports 1-10 images, and the qwen-image-3.0 series supports 1-3 images. When multiple images are provided, the order is defined by the array sequence.Image requirements:
string(Required)The positive prompt that describes the image content, style, and composition you want to generate or edit. Both Chinese and English are supported. Recommended maximum: 4,500 tokens.Note: Only one text object is allowed. Omitting it or providing multiple text objects will result in an error.object (Optional)Additional parameters to control image generation.
Properties prompt_extend boolean (Optional)Whether to enable intelligent prompt rewriting. Default: true (recommended). When enabled, the model optimizes the positive prompt using the method specified by prompt_extend_mode, which significantly improves results for simple descriptions.prompt_extend_mode string (Optional)The prompt rewriting method. Default: direct. Options:
boolean (Optional)Enables thinking mode. The default is true. This enhances model reasoning to improve image quality, but increases generation time. It requires prompt_extend=true. Supported for Direct T2I, Direct I2I, and Agent T2I. Not supported for I2I Agent.n integer (Optional)The number of output images. Value range: 1 to 6. Default: 1.size string (Optional)The output image resolution in the format width*height, for example "1024*1024". If not specified, the model automatically recommends a resolution based on the prompt.
string (Optional)The negative prompt that describes content you do not want to appear in the image. Only the qwen-image-3.0 series supports this parameter.seed integer (Optional)The random seed. Value range: [0, 2147483647]. If omitted, the service generates a random seed. Use a fixed seed for reproducible results.watermark boolean (Optional)Whether to add a watermark. Default: false. |
Response parametersoutputobjectContains the model generation results.
Properties rewrite_status stringThe prompt rewriting status. The value depends on whether rewriting was enabled in the request and the result of the rewrite.choices arrayThe list of result options.
Properties finish_reason stringThe reason why the task stopped. The value is stop when the task completes normally.message objectThe message returned by the model.
Properties role stringThe role of the message. Fixed as assistant.contentarrayThe message content containing the generated image information.
Properties image stringThe URL of the generated image in PNG format. The link is valid for 24 hours. Please download and save the image promptly.objectThe resource usage of this call. Only returned on success. These are image input and output metering fields, not token usage.
Properties
output_width integerThe width of the final output image in pixels.output_height integerThe height of the final output image in pixels.input_image_count integerThe number of input images in the request. Returns 0 for text-to-image (T2I), and the actual count for image-to-image (I2I).input_image_type stringThe input image billing tier. Determined by the output resolution pixel area: qima_input_1k if area ≤ 2,250,000, or qima_input_2k if area > 2,250,000.output_image_count integerThe actual number of output images returned.output_image_type stringThe output image billing tier. Determined by the output resolution pixel area: qima_output_1k if area ≤ 2,250,000, or qima_output_2k if area > 2,250,000.stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Task data (task status and image URLs) is retained for only 24 hours and then automatically purged. Save generated images promptly. |
SDK
The following examples demonstrate how to call the API using Python and Java SDKs for image-to-image / image editing (I2I).
DashScope asynchronous API
In addition to the synchronous call described above, Qwen Image Generation and Editing also supports asynchronous calls. The asynchronous API shares the same request parameter structure as the synchronous API. You only need to add the X-DashScope-Async: enable header. After the service accepts the request, it returns a task ID (task_id), which you then use to poll the query API for the final result.
HTTP
Asynchronous calls use a two-step workflow:
- Create a task to get a task ID: Send a request to create a task. The response contains a task ID (task_id).
- Poll for results using the task ID: Use the task_id to poll the task status until the task completes and the image URL is returned.
Step 1: Create a task to get a task ID
- Singapore
- US (Virginia)
- China (Beijing)
- China (Hong Kong)
- Germany (Frankfurt)
- Japan (Tokyo)
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generationRequest parametersHeadersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Async string (Required)Enables asynchronous processing. Must be enable. The endpoint in this section accepts asynchronous requests only and does not support synchronous calls.Request bodymodelstring (Required)The model name. Available values: qwen-image-3.0-pro, qwen-image-3.0, qwen-image-2.1-pro, and qwen-image-2.1-turbo.input object (Required)The input parameter object, which contains the following fields:
Properties messages array (Required)The request content array. Only single-round conversations are supported, so the array must contain exactly one object with role and content properties.
Properties role string (Required)The role of the message sender. Must be set to user.contentarray (Required)The message content array, with different combinations depending on the use case:
Properties image string (Required for I2I)The URL or Base64 encoded data of the input image. In I2I scenarios, the qwen-image-2.1 series supports 1-10 images, and the qwen-image-3.0 series supports 1-3 images. When multiple images are provided, the order is defined by the array sequence.Image requirements:
string(Required)The positive prompt that describes the image content, style, and composition you want to generate or edit. Both Chinese and English are supported. Recommended maximum: 4,500 tokens.Note: Only one text object is allowed. Omitting it or providing multiple text objects will result in an error.object (Optional)Additional parameters to control image generation.
Properties prompt_extend boolean (Optional)Whether to enable intelligent prompt rewriting. Default: true (recommended). When enabled, the model optimizes the positive prompt using the method specified by prompt_extend_mode, which significantly improves results for simple descriptions.prompt_extend_mode string (Optional)The prompt rewriting method. Default: direct. Options:
boolean (Optional)Enables thinking mode. The default is true. This enhances model reasoning to improve image quality, but increases generation time. It requires prompt_extend=true. Supported for Direct T2I, Direct I2I, and Agent T2I. Not supported for I2I Agent.n integer (Optional)The number of output images. Value range: 1 to 6. Default: 1.size string (Optional)The output image resolution in the format width*height, for example "1024*1024". If not specified, the model automatically recommends a resolution based on the prompt.
string (Optional)The negative prompt that describes content you do not want to appear in the image. Only the qwen-image-3.0 series supports this parameter.seed integer (Optional)The random seed. Value range: [0, 2147483647]. If omitted, the service generates a random seed. Use a fixed seed for reproducible results.watermark boolean (Optional)Whether to add a watermark. Default: false. |
Response parametersoutputobjectThe task acceptance information.
Properties task_id stringThe asynchronous task ID, used to query the task status and result. Make sure to save it.task_status stringThe task status. Usually PENDING when the task is submitted, indicating only that the task has been accepted, not that the image has been generated.stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Poll for results using the task ID
- Singapore
- US (Virginia)
- China (Beijing)
- China (Hong Kong)
- Germany (Frankfurt)
- Japan (Tokyo)
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.URL path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. The time is in UTC+8 and the format is YYYY-MM-DD HH:mm:ss.SSS.rewrite_status stringThe prompt rewriting status. The value depends on whether rewriting was enabled in the request and the result of the rewrite.choices arrayThe list of result options.
Properties finish_reason stringThe reason why the task stopped. The value is stop when the task completes normally.message objectThe message returned by the model.
Properties role stringThe role of the message. Fixed as assistant.contentarrayThe message content containing the generated image information.
Properties image stringThe URL of the generated image in PNG format. The link is valid for 24 hours. Please download and save the image promptly.objectThe resource usage of this call. Only returned on success. These are image input and output metering fields, not token usage.
Properties
output_width integerThe width of the final output image in pixels.output_height integerThe height of the final output image in pixels.input_image_count integerThe number of input images in the request. Returns 0 for text-to-image (T2I), and the actual count for image-to-image (I2I).input_image_type stringThe input image billing tier. Determined by the output resolution pixel area: qima_input_1k if area ≤ 2,250,000, or qima_input_2k if area > 2,250,000.output_image_count integerThe actual number of output images returned.output_image_type stringThe output image billing tier. Determined by the output resolution pixel area: qima_output_1k if area ≤ 2,250,000, or qima_output_2k if area > 2,250,000.stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Task data (task status and image URLs) is retained for only 24 hours and then automatically purged. Save generated images promptly. |