Skip to content
中文
Alibaba · Model API

Qwen Image 2.1 API

Qwen Image 2.1 API with VezAPI. Explore model capabilities, credit pricing, request parameters, and integration examples.

Text to ImageImage to Image

Qwen Image 2.1 API documentation

Integrate Qwen Image 2.1 with your VezAPI key. The operations below share the same authentication and account balance.

Base URL: https://api.vezapi.com
Send Authorization: Bearer YOUR_VEZAPI_KEY. Use a unique Idempotency-Key for each submission; reuse it only when checking the same request.

Qwen 2.1 - Image to Image

POST/api/v1/jobs/createTask

Model IDs: qwen2-1/image-to-image

ParameterTypeDescription & constraints
model
required
string

The model name used for generation. This endpoint must use `qwen2-1/image-to-image`.

Values: "qwen2-1/image-to-image"

Default: "qwen2-1/image-to-image"

callBackUrl
optional
string

Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent. To verify callbacks, see [Webhook Verification Guide](/common-api/webhook-verification).

input
required
object

Input parameters for the image-to-image generation task.

input.image_urls
required
array

Reference images, given as an array of 1 to 10 http(s) URLs. Required. The order of the array is the order the prompt refers to ("the first image", "the second image"). JPEG, PNG and WebP are supported, up to 30MB and 25MP each, and every URL must be directly retrievable with a GET. If an image URL cannot be fetched, the task fails with failCode 400. With more than 10 entries the request is rejected. The more references you supply the less detail each individual one keeps, so stay within 4 when fidelity matters. When combining several people or objects into a single picture, a landscape ratio such as `3:2` or `16:9` usually gives better results.

minItems: 1

maxItems: 10

input.prompt
required
string

The prompt describing the result you want. Required. Any language is supported, up to 5000 characters; if it is longer, the request is rejected. When `mask_url` is supplied, use it to describe what should be generated inside the white area of the mask.

minLength: 1

maxLength: 5000

input.mask_url
optional
string

Inpainting mask that switches the request into local-edit mode. A black and white image where **white marks the area to change and black is kept unchanged**, with a few pixels of feathering along the boundary. It must be used with exactly one entry in `image_urls`, otherwise the request is rejected. The mask should have the same aspect ratio as that reference image; a mask of a different size is scaled to it. In local-edit mode the output ratio follows the reference image, so `aspect_ratio` and `enhance_prompt` are ignored. It cannot be combined with `background: transparent`; such a request is rejected.

input.aspect_ratio
optional
string

Output aspect ratio. Defaults to `auto`, which takes the aspect ratio of the first reference image and snaps it to the nearest supported ratio. The actual pixel size also depends on `resolution`. Ignored in local-edit mode.

Values: "auto", "1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16", "21:9", "9:21"

Default: "auto"

input.resolution
optional
string

Output resolution tier. `1K` is the faster option; `2K` produces four times the pixels and takes considerably longer, up to about 3 minutes with reference images. Only `1K` and `2K` are accepted — with any other value, including `4K`, the request is rejected.

Values: "1K", "2K"

Default: "1K"

input.background
optional
string

Background type. transparent outputs a PNG or WebP with a real alpha channel and cannot be used with JPEG. When using transparent, describe only the subject — prompts that mention a background, scene, surface, etc. may produce a non-transparent result.

Values: "opaque", "transparent"

Default: "opaque"

input.output_format
optional
string

Output image format. `png` (default) and `webp` both carry an alpha channel and can be used with `background: transparent`. `jpeg` has no alpha channel and cannot be combined with a transparent background.

Values: "png", "webp", "jpeg"

Default: "png"

input.enhance_prompt
optional
boolean

Rewrites the prompt into a fuller scene description before generating, which noticeably improves quality. Enabled by default (also when the parameter is omitted); pass false to turn it off.

Default: true

input.seed
optional
integer

The random seed. Omit it to generate with a random seed. Passing the same seed together with the same prompt and parameters reproduces the same image within the same service version.

input.nsfw_checker
optional
boolean

Defaults to false. When false, no additional content filtering is applied and results are returned directly by the model.

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "qwen2-1/image-to-image",
  "input": {
    "image_urls": [
      "https://example.com/input.png",
      "https://example.com/input.png"
    ],
    "prompt": "Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged",
    "aspect_ratio": "auto",
    "resolution": "1K"
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

data
required
object
data.taskId
required
string

Task ID, can be used with Get Task Details endpoint to query task status

msg
optional
string

Response message, error description when failed

Qwen 2.1 - Text to Image

POST/api/v1/jobs/createTask

Model IDs: qwen2-1/text-to-image

ParameterTypeDescription & constraints
model
required
string

The model name used for generation. This endpoint must use `qwen2-1/text-to-image`.

Values: "qwen2-1/text-to-image"

Default: "qwen2-1/text-to-image"

callBackUrl
optional
string

Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent. To verify callbacks, see [Webhook Verification Guide](/common-api/webhook-verification).

input
required
object

Input parameters for the text-to-image generation task.

input.prompt
required
string

The prompt that describes the image content, style and composition you want to generate. Required. Any language is supported, up to 5000 characters; if it is longer, the request is rejected.

minLength: 1

maxLength: 5000

input.aspect_ratio
optional
string

The output aspect ratio. Default `1:1`. The actual pixel size also depends on `resolution`.

Values: "1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16", "21:9", "9:21"

Default: "1:1"

input.resolution
optional
string

The output resolution tier. `1K` is the faster option; `2K` produces four times the pixels and takes longer. Only `1K` and `2K` are accepted — with any other value, including `4K`, the request is rejected.

Values: "1K", "2K"

Default: "1K"

input.background
optional
string

Background type. transparent outputs a PNG or WebP with a real alpha channel and cannot be used with JPEG. When using transparent, describe only the subject — prompts that mention a background, scene, surface, etc. may produce a non-transparent result.

Values: "opaque", "transparent"

Default: "opaque"

input.output_format
optional
string

The output image format. `png` (default) and `webp` both carry an alpha channel and can be used with `background: transparent`. `jpeg` has no alpha channel and cannot be combined with a transparent background.

Values: "png", "webp", "jpeg"

Default: "png"

input.enhance_prompt
optional
boolean

Rewrites the prompt into a fuller scene description before generating, which noticeably improves quality. Enabled by default (also when the parameter is omitted); pass false to turn it off.

Default: true

input.seed
optional
integer

The random seed. Omit it to generate with a random seed. Passing the same seed together with the same prompt and parameters reproduces the same image within the same service version.

input.nsfw_checker
optional
boolean

Defaults to false. When false, no additional content filtering is applied and results are returned directly by the model.

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "qwen2-1/text-to-image",
  "input": {
    "prompt": "A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
optional
string

Response message, error description upon failure

data
required
object
data.taskId
required
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Task status and callbacks

For asynchronous tasks, keep the returned taskId. Query GET /api/v1/jobs/recordInfo?taskId=... or provide callBackUrl when creating the task. Only the account that created a task can access it or derive new resources from it.

A timeout can mean the submission was accepted. Inspect the existing request in your dashboard; do not create another task automatically. Callback delivery is retried and may arrive more than once. Deduplicate with X-VezAPI-Event-Id.

Files, logs and billing

Generated media normally follows a 14-day provider lifetime; uploaded files expire after 24 hours. Save the files you need before expiration. VezAPI streams registered files without keeping a permanent media library. Request logs are retained for two calendar months.

Credits are reserved before submission. Final deductions match actual discounted consumption one for one. Unknown usage pauses new paid requests. If available funds cannot cover final usage while protecting other reservations, settlement stays pending until funded; model usage cannot make the wallet negative. Time-based inputs require server-side metadata reads; a failed read prevents submission.

Open full documentation →

Qwen Image 2.1 API pricing

Rates below are reference estimates; final deductions equal actual discounted consumption, one for one. At the standard pack rate, 1,000 credits ≈ $10. Larger packs reduce the effective credit price.

SpecificationCreditsUnitUSD reference
Qwen-Image-2.1, image to image, 2K8per image$0.08
Qwen-Image-2.1, image to image, 1K4per image$0.04
Qwen-Image-2.1, text to image, 2K8per image$0.08
Qwen-Image-2.1, text to image, 1K4per image$0.04