外观
qwen-image-2.0-pro
qwen-image-2.0-pro 请求参数与示例。
POST /v1/images/generations · POST /v1/async/images/generations
POST /v1/images/edits · POST /v1/async/images/edits
发送 JSON,请求头填写 Authorization: Bearer <PIXAPI_KEY> 和 Content-Type: application/json。
请求字段
通用字段放在请求体一级,下面列出的模型专用参数放进 providerOptions。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | qwen-image-2.0-pro. 模型 ID,区分大小写。 |
prompt | string | 是 | 描述主体、构图、风格或需要修改的内容。Pixapi 最多保留前 2,000 字符;生成和编辑都要提供非空提示词。 |
n | integer | 否 | 整数 1–6,默认 1。 |
size | string | 否 | 填写 宽x高 像素尺寸,例如 1024x1024。 总像素 512×512–2048×2048。 文生图默认 2048x2048,编辑跟随参考图比例;不接受 auto。 |
image | string / string[] | 编辑时必填 | 公网 HTTP(S) 图片 URL 或 URL 数组;/images/edits 必填。 1–3 张,每张 ≤ 10 MB,建议宽高各 384–2048 像素,支持 JPEG/PNG/BMP/TIFF/WebP/GIF。 也接受完整 data:image/...;base64,...(每张 ≤10 MB、合计 ≤20 MB),不接受裸 Base64 或文件上传。 |
providerOptions | object | 否 | 模型专用选项,详见下表。 |
providerOptions
本表所有字段都写在 providerOptions 内,不要与 model 并列。
| 字段 | 类型 | 说明 |
|---|---|---|
seed | integer | 随机种子 0–2147483647;省略时随机。相同种子不保证输出完全一致。 |
prompt_extend | boolean | 是否优化和扩展提示词,默认 true。 |
negative_prompt | string | 描述不希望出现的内容,最多 500 字符。 |
watermark | boolean | 是否添加 AI 可见水印,默认 false。 |
输入规则
请求体使用 JSON。这些百炼模型不传 quality、resolution、mask、output_format;Z-Image 仅支持文生图。
示例
bash
curl https://api.pixapi.ai/v1/images/generations \
-H "Authorization: Bearer $PIXAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.0-pro",
"prompt": "A poster for a coffee shop with the title Good Morning",
"n": 1,
"size": "1024x1024",
"providerOptions": {
"prompt_extend": true
}
}'py
import os
import requests
response = requests.post(
"https://api.pixapi.ai/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['PIXAPI_KEY']}"},
json={
"model": "qwen-image-2.0-pro",
"prompt": "A poster for a coffee shop with the title Good Morning",
"n": 1,
"size": "1024x1024",
"providerOptions": {
"prompt_extend": True
}
},
)
response.raise_for_status()
print(response.json())js
const response = await fetch('https://api.pixapi.ai/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PIXAPI_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "qwen-image-2.0-pro",
"prompt": "A poster for a coffee shop with the title Good Morning",
"n": 1,
"size": "1024x1024",
"providerOptions": {
"prompt_extend": true
}
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"model": "qwen-image-2.0-pro",
"prompt": "A poster for a coffee shop with the title Good Morning",
"n": 1,
"size": "1024x1024",
"providerOptions": {
"prompt_extend": true
}
}`)
req, err := http.NewRequest("POST", "https://api.pixapi.ai/v1/images/generations", bytes.NewBuffer(body))
if err != nil { panic(err) }
req.Header.Set("Authorization", "Bearer " + os.Getenv("PIXAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
result, err := io.ReadAll(resp.Body)
if err != nil { panic(err) }
if resp.StatusCode >= 400 { panic(string(result)) }
fmt.Println(string(result))
}异步请求保存返回的 id,用 GET /v1/tasks/{id} 查询至 completed 或 failed。参阅查询结果和计费说明。
