Qwen Image
curl --request POST \
--url https://api.mixroute.ai/v1/images/generationsimport requests
url = "https://api.mixroute.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyImage Series
Qwen Image
Qwen Image image generation fields, model constraints, and request examples.
Qwen Image
curl --request POST \
--url https://api.mixroute.ai/v1/images/generationsimport requests
url = "https://api.mixroute.ai/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyQwen image generation uses two request formats depending on the model. Both call the same MixRoute endpoint; do not mix input.prompt with input.messages.
For reference-image editing, use the Qwen Image editing page and the qwen-image-edit* models. These request formats do not add a metadata or asset wrapper.
POST https://api.mixroute.ai/v1/images/generations
Model Selection
| Models | Input Format | Image URLs |
|---|---|---|
qwen-image, qwen-image-plus | input.prompt | output.results[].url |
qwen-image-2.0, qwen-image-2.0-pro, qwen-image-max | input.messages | output.choices[].message.content[].image |
Basic Text-to-Image
Use qwen-image or qwen-image-plus. The input object contains prompt, not messages.Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Complete model ID from the applicable model table. |
input | object | Yes | Input object. |
input.prompt | string | Yes | Text prompt. Chinese and English may be combined. Describe the desired content, style, and composition. |
parameters | object | No | Optional generation settings. |
parameters.size | string | No | Dimensions written as width*height, such as 1024*1024 or 1664*928. Use an asterisk, not x. |
parameters.n | integer | No | Only 1 is supported per request. Make separate requests for multiple images. |
Request Examples
Set your MixRoute key in theMIXROUTE_API_KEY environment variable.
curl --request POST "https://api.mixroute.ai/v1/images/generations" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "qwen-image-plus",
"input": {
"prompt": "A clean product photograph of a red ceramic mug on a white background."
},
"parameters": {
"size": "1024*1024",
"n": 1
}
}'
import json
import os
import requests
payload = json.loads(r'''
{
"model": "qwen-image-plus",
"input": {
"prompt": "A clean product photograph of a red ceramic mug on a white background."
},
"parameters": {
"size": "1024*1024",
"n": 1
}
}
''')
response = requests.post(
"https://api.mixroute.ai/v1/images/generations",
headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
json=payload,
timeout=180,
)
response.raise_for_status()
result = response.json()
output = result.get("output") or {}
if output.get("task_status") != "SUCCEEDED":
raise RuntimeError(result.get("message") or result)
image_urls = [item["url"] for item in output.get("results", []) if item.get("url")]
if not image_urls:
raise RuntimeError(result.get("message") or result)
for url in image_urls:
print(url)
Response
A successful result has output.task_status=“SUCCEEDED”. Read temporary image URLs from output.results[].url and save the images promptly; usage.image_count is the actual output count.{
"output": {
"task_status": "SUCCEEDED",
"results": [
{
"url": "https://example.com/generated.png"
}
]
},
"usage": {
"image_count": 1
}
}
Multimodal-Format Text-to-Image
Use qwen-image-2.0, qwen-image-2.0-pro, or qwen-image-max with one user message and one text block. The request uses the multimodal envelope, but these models are listed here for text-only generation.Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Complete model ID from the applicable model table. |
input | object | Yes | Input object. |
input.messages | array | Yes | Exactly one user message. |
input.messages[].role | string | Yes | Must be user. |
input.messages[].content | array | Yes | One text block for text-to-image. Do not include reference images for the generation models listed here. |
input.messages[].content[].text | string | Per content block | Prompt text in the text block. |
parameters | object | No | Optional generation settings. |
parameters.size | string | No | Dimensions written as width*height, such as 1024*1024 or 1664*928. Use an asterisk, not x. |
parameters.n | integer | No | Only 1 is supported per request. Make separate requests for multiple images. |
parameters.seed | integer | No | Random seed. Reusing a prompt and seed can give similar results; it is not a guarantee of identical output. |
parameters.watermark | boolean | No | Whether to add a watermark. |
parameters.negative_prompt | string | No | Elements to avoid in the generated image. |
parameters.prompt_extend | boolean | No | Whether to let the upstream service expand the prompt with additional detail. |
Request Examples
curl --request POST "https://api.mixroute.ai/v1/images/generations" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "qwen-image-2.0-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A clean product photograph of a red ceramic mug on a white background."
}
]
}
]
},
"parameters": {
"size": "1024*1024",
"n": 1,
"seed": 42
}
}'
import json
import os
import requests
payload = json.loads(r'''
{
"model": "qwen-image-2.0-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "A clean product photograph of a red ceramic mug on a white background."
}
]
}
]
},
"parameters": {
"size": "1024*1024",
"n": 1,
"seed": 42
}
}
''')
response = requests.post(
"https://api.mixroute.ai/v1/images/generations",
headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
json=payload,
timeout=180,
)
response.raise_for_status()
result = response.json()
output = result.get("output") or {}
image_urls = [
part["image"]
for choice in output.get("choices", [])
for part in choice.get("message", {}).get("content", [])
if part.get("image")
]
if not image_urls:
raise RuntimeError(result.get("message") or result)
for url in image_urls:
print(url)
Response
Read image URLs from output.choices[].message.content[].image. usage.image_count, usage.height, and usage.width describe the output. Do not parse this response with the basic interface’s output.results path.{
"output": {
"choices": [
{
"message": {
"role": "assistant",
"content": [
{
"image": "https://example.com/generated.png"
}
]
}
}
]
},
"usage": {
"image_count": 1,
"height": 1024,
"width": 1024
}
}