Qwen Image Edit API Documentation
Image Edit(Img2Img) - Request Code
POST https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageEditRequest HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"model": "qwen-image-edit",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg"
},
{
"text": "Change the person to a walking position, bending over to hold the bear's front paws."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"watermark": false
}
} import requests
url = "https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageEditRequest"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"model": "qwen-image-edit",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg"
},
{
"text": "Change the person to a walking position, bending over to hold the bear's front paws."
}
]
}
]
},
"parameters": {
"negative_prompt": "",
"watermark": False
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const url = 'https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageEditRequest';
const headers = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
};
const data = {
model: 'qwen-image-edit',
input: {
messages: [
{
role: 'user',
content: [
{
image: 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg'
},
{
text: 'Change the person to a walking position, bending over to hold the bear\'s front paws.'
}
]
}
]
},
parameters: {
negative_prompt: '',
watermark: false
}
};
fetch(url, {
method: 'POST',
headers: headers,
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/generateMultimodeTextToImageEditRequest" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" --data-raw '{
"model": "qwen-image-edit",
"input": {
"messages": [{
"role": "user",
"content": [{
"image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg"
}, {
"text": "Change the person to a walking position, bending over to hold the bear\'s front paws."
}]
}]
},
"parameters": {
"negative_prompt": "",
"watermark": false
}
}'
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 ApiClient {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageEditRequest";
String json = "{" + "\n" +
" \"model\": \"qwen-image-edit\"," + "\n" +
" \"input\": {" + "\n" +
" \"messages\": [{" + "\n" +
" \"role\": \"user\"," + "\n" +
" \"content\": [{" + "\n" +
" \"image\": \"https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg\"" + "\n" +
" }, {" + "\n" +
" \"text\": \"Change the person to a walking position, bending over to hold the bear's front paws.\"" + "\n" +
" }]" + "\n" +
" }]" + "\n" +
" }," + "\n" +
" \"parameters\": {" + "\n" +
" \"negative_prompt\": \"\"," + "\n" +
" \"watermark\": false" + "\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(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = 'https://gateway.pixazo.ai/qwen-image/v1/generateMultimodeTextToImageEditRequest';
$data = [
'model' => 'qwen-image-edit',
'input' => [
'messages' => [
[
'role' => 'user',
'content' => [
[
'image' => 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg'
],
[
'text' => 'Change the person to a walking position, bending over to hold the bear\'s front paws.'
]
]
]
]
],
'parameters' => [
'negative_prompt' => '',
'watermark' => false
]
];
$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);
curl_close($ch);
echo $response;
?> Output
Successful API response:
{ "status_code": 200, "request_id": "3daccb10-10ca-9399-8b6a-xxxxxx", "output": { "choices": [ { "message": { "content": [ { "image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/qwen-image-edit/..." } ] } } ] } } Request Body - Image Edit(Img2Img)
Parameters for /generateMultimodeTextToImageEditRequest:
| Parameter | Required | Type | Description |
|---|---|---|---|
| model | Yes | string | Model to use. Available value: "qwen-image-edit" (Qwen image editing model). |
| input.messages | Yes | array | Array of message objects containing the image editing request. Must contain at least one user message. |
| input.messages[].role | Yes | string | Role of the message sender. Must be "user" for image editing requests. |
| input.messages[].content | Yes | array | Array of content objects containing both the input image and editing instructions. |
| input.messages[].content[].image | Yes | string | Input image for editing. Can be a publicly accessible HTTP/HTTPS URL or Base64-encoded image data in format data:{MIME_type};base64,{base64_data}. |
| input.messages[].content[].text | Yes | string | Text instructions describing the desired edits. Supports complex editing tasks including text editing, color adjustment, style transfer, and object manipulation. |
| parameters.negative_prompt | No | string | Negative prompt to specify what should not appear in the edited image. Default: "" (empty string). |
| parameters.watermark | No | boolean | Whether to add a watermark to the edited image. Default: false. |
Example Request - Image Edit(Img2Img)
JSON
{ "model": "qwen-image-edit", "input": { "messages": [ { "role": "user", "content": [ { "image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/manwithbear.jpg" }, { "text": "Change the person to a walking position, bending over to hold the bear's front paws." } ] } ] }, "parameters": { "negative_prompt": "", "watermark": false } } Response - Image Edit(Img2Img)
JSON
{ "status_code": 200, "request_id": "3daccb10-10ca-9399-8b6a-xxxxxx", "code": "", "message": "", "output": { "text": null, "finish_reason": null, "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": [ { "image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/qwen-image-edit/qwen-image-edit-3daccb10-10ca-9399-8b6a-xxxxxx-1703123456789.png" } ] } } ] }, "usage": { "input_tokens": 0, "output_tokens": 0, "width": 1248, "image_count": 1, "height": 832 } } Request Headers
| Header | Description |
|---|---|
| Content-Type | application/json |
| Cache-Control | 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 Edit API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $0.055 |
Ready to generate Qwen Image Edit API assets?
Start with an API key, then automate your pipeline.