Qwen Image API Documentation
Text To Image Request - Request Code
POST https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"model": "qwen-image",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads 'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.' The right scroll reads 'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.' The horizontal scroll reads 'Wisdom enlightens Tongyi.' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"prompt_extend": true,
"watermark": true,
"size": "1328*1328"
}
} import requests
import json
url = "https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"model": "qwen-image",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads 'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.' The right scroll reads 'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.' The horizontal scroll reads 'Wisdom enlightens Tongyi.' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"prompt_extend": true,
"watermark": true,
"size": "1328*1328"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const url = 'https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest';
const data = {
model: 'qwen-image',
input: {
messages: [
{
role: 'user',
content: [
{
text: 'An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads \'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.\' The right scroll reads \'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.\' The horizontal scroll reads \'Wisdom enlightens Tongyi.\' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle.'
}
]
}
]
},
parameters: {
negative_prompt: '',
prompt_extend: true,
watermark: true,
size: '1328*1328'
}
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
curl -v -X POST "https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
--data-raw '{
"model": "qwen-image",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads \"Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.\" The right scroll reads \"Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.\" The horizontal scroll reads \"Wisdom enlightens Tongyi.\" The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"prompt_extend": true,
"watermark": true,
"size": "1328*1328"
}
}'
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class QwenImageExample {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest";
String jsonBody = "{" + "\n" +
" \"model\": \"qwen-image\"," + "\n" +
" \"input\": {" + "\n" +
" \"messages\": [" + "\n" +
" {" + "\n" +
" \"role\": \"user\"," + "\n" +
" \"content\": [" + "\n" +
" {" + "\n" +
" \"text\": \"An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads 'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.' The right scroll reads 'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.' The horizontal scroll reads 'Wisdom enlightens Tongyi.' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle.\"" + "\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }," + "\n" +
" \"parameters\": {" + "\n" +
" \"negative_prompt\": \"\"," + "\n" +
" \"prompt_extend\": true," + "\n" +
" \"watermark\": true," + "\n" +
" \"size\": \"1328*1328\"" + "\n" +
" }\n" +
"}";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Cache-Control", "no-cache")
.header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
} <?php
$url = 'https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageRequest';
$data = [
'model' => 'qwen-image',
'input' => [
'messages' => [
[
'role' => 'user',
'content' => [
[
'text' => 'An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads \'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.\' The right scroll reads \'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.\' The horizontal scroll reads \'Wisdom enlightens Tongyi.\' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle.'
]
]
]
]
],
'parameters' => [
'negative_prompt' => '',
'prompt_extend' => true,
'watermark' => true,
'size' => '1328*1328'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cache-Control: no-cache',
'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
?> Output
Successful API response:
{ "output": { "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": [ { "image": "<IMAGE_URL>" } ] } } ], "task_metric": { "TOTAL": 1, "FAILED": 0, "SUCCEEDED": 1 } }, "usage": { "width": 1328, "image_count": 1, "height": 1328 }, "request_id": "7a270c86-db58-9faf-b403-xxxxxx" } Request Body - Text To Image Request
Parameters for /generateMultimodeTextToImageRequest:
| Parameter | Required | Type | Description |
|---|---|---|---|
| model | Yes | string | Model to use. Available value: "qwen-image" (Qwen text-to-image generation model). |
| input.messages | Yes | array | Array of message objects containing the generation request. Must contain at least one user message. |
| input.messages[].role | Yes | string | Role of the message sender. Must be "user" for text-to-image generation requests. |
| input.messages[].content | Yes | array | Array of content objects containing the text prompt for image generation. |
| input.messages[].content[].text | Yes | string | Text prompt describing the image to generate. Supports complex descriptions, multi-line layouts, and fine-grained details. Excels at Chinese and English text rendering. |
| parameters.negative_prompt | No | string | Negative prompt to specify what should not appear in the generated image. Default: "" (empty string). |
| parameters.prompt_extend | No | boolean | Whether to extend and enhance the input prompt automatically. Default: true. |
| parameters.watermark | No | boolean | Whether to add a watermark to the generated image. Default: true. |
| parameters.size | No | string | Output image dimensions in format "WIDTHxHEIGHT". Available sizes: "1328*1328", "1024*1024", "768*768", "512*512". Default: "1328*1328". |
Example Request - Text To Image Request
JSON
{ "model": "qwen-image", "input": { "messages": [ { "role": "user", "content": [ { "text": "An elegant and solemn couplet hangs in a hall. The room has a quiet and classic Chinese decor. The left scroll reads 'Righteousness is the root of innate knowledge; humans and machines share the same path and excel in new thinking.' The right scroll reads 'Connecting clouds grants wisdom; the universe reveals numbers, inspiring lofty ambitions.' The horizontal scroll reads 'Wisdom enlightens Tongyi.' The calligraphy is flowing. A Chinese-style painting of Yueyang Tower hangs in the middle." } ] } ] }, "parameters": { "negative_prompt": "", "prompt_extend": true, "watermark": true, "size": "1328*1328" } } Response - Text To Image Request
JSON
{ "output": { "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": [ { "image": "https://example.com/generated-image.png" } ] } } ], "task_metric": { "TOTAL": 1, "FAILED": 0, "SUCCEEDED": 1 } }, "usage": { "width": 1328, "image_count": 1, "height": 1328 }, "request_id": "7a270c86-db58-9faf-b403-xxxxxx" } Request Headers
| Header | Description |
|---|---|
| Content-Type | Must be set to application/json |
| Cache-Control | Must be set to no-cache |
| Ocp-Apim-Subscription-Key | Your subscription key for authentication |
Response Handling
The Qwen Image returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement error handling in their applications to manage these responses effectively.
Common Status Codes and Responses
| Status Code | Description | Response Body |
|---|---|---|
| 200 | Success - The request was successfully processed. | { "success": true, ... } |
| 400 | Bad Request - The request contains invalid parameters or missing fields. | { "error": "Invalid request parameters" } |
| 401 | Unauthorized - The provided subscription key is missing or invalid. | { "error": "Invalid or missing authentication" } |
| 403 | Forbidden - The subscription does not have access to this API or action. | { "error": "Access denied for this operation" } |
| 404 | Not Found - The requested resource or endpoint could not be found. | { "error": "Endpoint not found" } |
| 429 | Too Many Requests - The request rate limit has been exceeded. | { "error": "Rate limit exceeded, please retry later" } |
| 500 | Internal Server Error - An unexpected error occurred on the server. | { "error": "An unexpected error occurred, please try again later" } |
Example Error Response
{
"error": "Invalid parameters"
} Qwen Image API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $0.045 |
Ready to generate Qwen Image API assets?
Start with an API key, then automate your pipeline.