Qwen/Qwen-Image API
This document introduces the input and output parameters of the Qwen/Qwen-Image model API, for your reference when using the interface.
Request Parameters
Request Body
| Field Name | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Required | - | Prompt |
| model | string | Required | - | The model name used for this request, here it is Qwen/Qwen-Image. |
| seed | int | Optional | -1 | Random seed for controlling the randomness of the model generation content. For consistent outputs, use the same seed value. |
| size | string | Optional | - | Size of the generated image (width x height), each dimension ranging from 256 to 1536. For example: 1024x1024 |
Response Parameters
| Field Name | Type | Description |
|---|---|---|
| created | integer | The Unix timestamp (in seconds) when this request was created. |
| data | array | Information about the output image, including the URL for download or Base64. • If the return format for the generated image is specified as url, the subfield is url; • If the return format is specified as b64_json, the subfield is b64_json. Note: Links will expire within 7 days upon generation, please save images promptly. |
| error | Object | Error information object |
| error.code | string | Error code |
| error.message | string | Error message |
| error.param | string | Request id |
Examples
OPENAI Compatible Interface
POST https://api.umodelverse.ai/v1/images/generations
Synchronous Request
curl --location 'https://api.umodelverse.ai/v1/images/generations' \
--header "Authorization: Bearer $MODELVERSE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "Qwen/Qwen-Image",
"prompt": "Convert to quick pencil sketch",
"size": "1024x1024"
}'import os
from openai import OpenAI
client = OpenAI(
base_url=os.getenv("BASE_URL", "https://api.umodelverse.ai/v1"),
api_key=os.getenv("API_KEY", "$MODELVERSE_API_KEY")
)
response = client.images.generate(
model="Qwen/Qwen-Image",
prompt="Convert to quick pencil sketch",
size="1024x1024"
)
print(response.data[0].url)Response
{
"created": 1750667997,
"data": [
{
"url": "https://xxxxx/xxxx.png",
"b64_json": "data:image/png;base64,{image_base64_string}"
}
],
"usage": {
"input_tokens_details": {}
}
}{
"error": {
"message": "error_message",
"type": "error_type",
"param": "request_id",
"code": "error_code"
}
}