curl --request POST \
--url https://api.goenhance.ai/api/v1/images/generations \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-image-2-1",
"prompt": "A red panda barista making latte art in a cozy wooden cafe, warm morning light",
"ratio": "16:9",
"image_size": "1K"
}
'import requests
url = "https://api.goenhance.ai/api/v1/images/generations"
payload = {
"model": "qwen-image-2-1",
"prompt": "A red panda barista making latte art in a cozy wooden cafe, warm morning light",
"ratio": "16:9",
"image_size": "1K"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'qwen-image-2-1',
prompt: 'A red panda barista making latte art in a cozy wooden cafe, warm morning light',
ratio: '16:9',
image_size: '1K'
})
};
fetch('https://api.goenhance.ai/api/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.goenhance.ai/api/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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'qwen-image-2-1',
'prompt' => 'A red panda barista making latte art in a cozy wooden cafe, warm morning light',
'ratio' => '16:9',
'image_size' => '1K'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goenhance.ai/api/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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.goenhance.ai/api/v1/images/generations")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goenhance.ai/api/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "Success",
"data": {
"img_uuid": "c12b656c-747a-44fd-9c80-add79b0c52d5",
"cost": 1
}
}Qwen-Image 2.1
Qwen-Image 2.1 in a single endpoint: text to image, editing with up to 10 reference images, transparent PNG output, and background removal. Omit image_list for text to image; pass it to edit. Always returns a single PNG.
Pricing — flat per image by resolution tier. Text to image, editing and transparent output cost the same, and reference images add nothing:
| image_size | Tokens | USD |
|---|---|---|
| 1K (about 1 MP, default) | 1 | $0.02 |
| 2K (about 4 MP, native) | 4 | $0.08 |
Editing and reference images
- Refer to the images in the prompt as
<image1>,<image2>… inimage_listorder.image1is the image being edited; the rest are references. - Up to 10 images at 1K. At 2K the limit is 3, because every reference is also encoded at 2K.
- With
ratio: auto(the default when editing) the output keeps the aspect ratio ofimage1. Choosing a ratio far fromimage1can shift the edit. - PNG references with transparency are read with their alpha channel.
Transparent background — set background to transparent for a PNG with an alpha channel, for both text to image and editing. To remove the background of one image, send one image in image_list with background: transparent and no prompt.
- Fully transparent pixels carry an arbitrary colour underneath. Composite the PNG over your own background before converting to JPEG, or the transparent area turns into a solid colour.
- Transparent materials such as glass or lenses come out opaque.
- For plain cut-outs, Background Remover is cheaper and gives cleaner hair edges.
Timing — about 30 to 60 seconds of processing for 1K, and about 3 to 7 minutes for 2K, plus queue time.
curl --request POST \
--url https://api.goenhance.ai/api/v1/images/generations \
--header 'Content-Type: application/json' \
--data '
{
"model": "qwen-image-2-1",
"prompt": "A red panda barista making latte art in a cozy wooden cafe, warm morning light",
"ratio": "16:9",
"image_size": "1K"
}
'import requests
url = "https://api.goenhance.ai/api/v1/images/generations"
payload = {
"model": "qwen-image-2-1",
"prompt": "A red panda barista making latte art in a cozy wooden cafe, warm morning light",
"ratio": "16:9",
"image_size": "1K"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'qwen-image-2-1',
prompt: 'A red panda barista making latte art in a cozy wooden cafe, warm morning light',
ratio: '16:9',
image_size: '1K'
})
};
fetch('https://api.goenhance.ai/api/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.goenhance.ai/api/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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'qwen-image-2-1',
'prompt' => 'A red panda barista making latte art in a cozy wooden cafe, warm morning light',
'ratio' => '16:9',
'image_size' => '1K'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goenhance.ai/api/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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.goenhance.ai/api/v1/images/generations")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goenhance.ai/api/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"qwen-image-2-1\",\n \"prompt\": \"A red panda barista making latte art in a cozy wooden cafe, warm morning light\",\n \"ratio\": \"16:9\",\n \"image_size\": \"1K\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "Success",
"data": {
"img_uuid": "c12b656c-747a-44fd-9c80-add79b0c52d5",
"cost": 1
}
}Headers
Body
Model name. Must be qwen-image-2-1.
qwen-image-2-1 What to generate, or the edit instruction. Refer to reference images as <image1> … <image10>. Required, except for background removal (one image in image_list with background: transparent). Any language is accepted, and text you ask for in the image is rendered as written.
4000Optional reference images for editing, [{"url": "https://..."}]. Up to 10 at 1K, up to 3 at 2K. The array order is the <imageN> order; the first image is the one being edited. Reference images do not change the price.
1 - 10 elementsShow child attributes
Show child attributes
Aspect ratio. auto follows the first reference image when editing and means 1:1 for text to image.
auto, 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9 Resolution tier, also the price tier. 1K is about 1 megapixel, 2K about 4 megapixels (native). Case-insensitive.
1K, 2K transparent returns a PNG with an alpha channel. Does not affect pricing.
opaque, transparent Optional. Fixing the seed makes results more reproducible.
0 <= x <= 2147483647Optional. A publicly accessible HTTPS URL. When the task status changes (processing / success / failed), GoEnhance sends a POST request to this URL. The request body is identical to the response of GET /api/v1/jobs/detail. If your server does not respond with HTTP 200, the notification is retried up to 3 times, with a 3-second timeout per attempt.
"https://your-server.com/goenhance/callback"
