
开始接入
浏览常见问题接口预览
API 接入示例
提交任务后,使用响应中 Location 指向的地址查询进度和生成结果。
服务端环境变量
PIXQUEUE_GENERATION_URL- 以 /generations 结尾的完整接口地址
PIXQUEUE_API_KEY- 你的 API 密钥
PIXQUEUE_IDEMPOTENCY_KEY- 每个新任务使用一个唯一值,重试同一任务时沿用原值。
import json
import os
from urllib.request import Request, urlopen
payload = {
"model": "Qwen-Image-2.1",
"prompt": "月光下的雪山,云海环绕",
"width": 1024,
"height": 1024
}
request = Request(
os.environ["PIXQUEUE_GENERATION_URL"],
method="POST",
headers={
"Authorization": "Bearer " + os.environ["PIXQUEUE_API_KEY"],
"Idempotency-Key": os.environ["PIXQUEUE_IDEMPOTENCY_KEY"],
"Content-Type": "application/json",
},
data=json.dumps(payload).encode("utf-8"),
)
with urlopen(request, timeout=60) as response:
print(response.status, response.headers["Location"])const payload = {
"model": "Qwen-Image-2.1",
"prompt": "月光下的雪山,云海环绕",
"width": 1024,
"height": 1024
};
const response = await fetch(process.env.PIXQUEUE_GENERATION_URL, {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.PIXQUEUE_API_KEY,
"Idempotency-Key": process.env.PIXQUEUE_IDEMPOTENCY_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
signal: AbortSignal.timeout(60_000),
});
if (!response.ok) throw new Error("HTTP " + response.status);
console.log(response.status, response.headers.get("Location"));package main
import (
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
)
func main() {
body := strings.NewReader(`{
"model": "Qwen-Image-2.1",
"prompt": "月光下的雪山,云海环绕",
"width": 1024,
"height": 1024
}`)
req, err := http.NewRequest(http.MethodPost, os.Getenv("PIXQUEUE_GENERATION_URL"), body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer " + os.Getenv("PIXQUEUE_API_KEY"))
req.Header.Set("Idempotency-Key", os.Getenv("PIXQUEUE_IDEMPOTENCY_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 60 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
fmt.Println(res.Status, res.Header.Get("Location"))
}curl --request POST "$PIXQUEUE_GENERATION_URL" \
--header "Authorization: Bearer $PIXQUEUE_API_KEY" \
--header "Idempotency-Key: $PIXQUEUE_IDEMPOTENCY_KEY" \
--header "Content-Type: application/json" \
--include --max-time 60 --fail-with-body \
--data-binary '{
"model": "Qwen-Image-2.1",
"prompt": "月光下的雪山,云海环绕",
"width": 1024,
"height": 1024
}'POST · application/json
常见问题
关于账号、模型选择和按量计价。