通义千问(图像)
curl --request POST \
--url https://api.gravitex.ai/v1/images/generations \
--header 'Authorization: <authorization>'import requests
url = "https://api.gravitex.ai/v1/images/generations"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.gravitex.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.gravitex.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",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$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.gravitex.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.gravitex.ai/v1/images/generations")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body图像系列
通义千问(图像)
百炼 Qwen Image 文生图与图像编辑
POST
/
v1
/
images
/
generations
通义千问(图像)
curl --request POST \
--url https://api.gravitex.ai/v1/images/generations \
--header 'Authorization: <authorization>'import requests
url = "https://api.gravitex.ai/v1/images/generations"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.gravitex.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.gravitex.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",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$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.gravitex.ai/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.gravitex.ai/v1/images/generations")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body简介
通义千问图像系列(百炼 Qwen Image)支持中文场景文生图与多图编辑。通过 OpenAI 兼容接口调用:- 文生图:
POST /v1/images/generations,模型qwen-image-plus - 图像编辑:
POST /v1/images/edits,模型qwen-image-edit-plus
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx支持的模型
| 模型 ID | 说明 | 端点 |
|---|---|---|
qwen-image-plus | 文生图 | /v1/images/generations |
qwen-image-edit-plus | 图生图 / 图像编辑(1–3 张输入图) | /v1/images/edits |
请求示例
- 文生图
- 图像编辑
curl -X POST "https://api.gravitex.ai/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-plus",
"input": {
"messages": [
{
"role": "user",
"content": [
{"text": "一副典雅庄重的对联悬挂于中式厅堂,横批「智启通义」,水墨风格"}
]
}
]
},
"parameters": {
"prompt_extend": true,
"watermark": false
}
}'
curl -X POST "https://api.gravitex.ai/v1/images/edits" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-edit-plus",
"input": {
"messages": [
{
"role": "user",
"content": [
{"image": "https://example.com/reference.webp"},
{"text": "生成符合参考图的图像:红色自行车停在泥泞小路,背景为原始森林"}
]
}
]
},
"parameters": {
"n": 2,
"size": "2048*2048",
"prompt_extend": true,
"watermark": false
}
}'
常用参数
- input.messages:Qwen 消息结构,
content中为text和/或image - parameters.prompt_extend:是否扩展提示词(编辑系列建议短 prompt 开启、长 prompt 关闭)
- parameters.n:输出张数;
qwen-image-edit-plus支持 1–6 张 - parameters.size:输出尺寸,如
2048*2048 - response_format:支持
url或b64_json
qwen-image-plus 仅文生图,不支持参考图输入。多图编辑请使用 qwen-image-edit-plus 并走 /v1/images/edits。⌘I
