Qwen Image Editing
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 Editing
Qwen Image image editing fields, model constraints, and request examples.
Qwen Image Editing
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_bodyEdit reference images with Qwen Image using one user message containing text and image blocks.
Use Qwen Image generation for qwen-image, qwen-image-plus, qwen-image-2.0, qwen-image-2.0-pro, and qwen-image-max.
POST https://api.mixroute.ai/v1/images/generations
Models
| Model ID | Input |
|---|---|
qwen-image-edit | One text block and 1-3 reference-image blocks. |
qwen-image-edit-plus | One text block and 1-3 reference-image blocks. |
qwen-image-edit-max | One text block and 1-3 reference-image blocks. |
Request 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 plus 1-3 image blocks. Each block contains text or image, not both. |
input.messages[].content[].text | string | Per content block | Prompt text in the text block. |
input.messages[].content[].image | string | Per content block | Publicly accessible HTTPS reference-image URL, downloaded by the upstream service. Provide 1-3 image blocks. |
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. |
Put text and image in separate content blocks. Reference images must use public HTTPS URLs accessible to the upstream service. Use input.messages rather than input.prompt; do not send a top-level prompt, multipart files, Base64 data URIs, or a metadata wrapper.
Request Examples
SetMIXROUTE_API_KEY and replace the reference-image placeholder with a public HTTPS image URL.
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-edit",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "Change the mug to blue while preserving the background."
},
{
"image": "https://example.com/reference.png"
}
]
}
]
},
"parameters": {
"size": "1024*1024",
"n": 1,
"seed": 42
}
}'
Python
import json
import os
import requests
payload = json.loads(r'''
{
"model": "qwen-image-edit",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "Change the mug to blue while preserving the background."
},
{
"image": "https://example.com/reference.png"
}
]
}
]
},
"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. This response does not use the basic text-to-image output.results structure.{
"output": {
"choices": [
{
"message": {
"role": "assistant",
"content": [
{
"image": "https://example.com/generated.png"
}
]
}
}
]
},
"usage": {
"image_count": 1,
"height": 1024,
"width": 1024
}
}