Skip to content

z-image-turbo ​

z-image-turbo 请求参数与示例。

POST /v1/images/generations · POST /v1/async/images/generations

发送 JSON,请求头填写 Authorization: Bearer <PIXAPI_KEY> 和 Content-Type: application/json。

请求字段 ​

通用字段放在请求体一级,下面列出的模型专用参数放进 providerOptions。

字段类型必填说明
modelstring是z-image-turbo. 模型 ID,区分大小写。
promptstring是非空中英文描述,最多 800 字符,超出会报错。
ninteger否默认 1,只支持整数 1。
sizestring否填写 宽x高 像素尺寸,例如 1024x1024。 总像素 512×512–2048×2048。 宽高各 512–2048,默认 1024x1536,不接受 auto。
providerOptionsobject否模型专用选项,详见下表。

providerOptions ​

本表所有字段都写在 providerOptions 内,不要与 model 并列。

字段类型说明
seedinteger随机种子 0–2147483647;省略时随机。相同种子不保证输出完全一致。
prompt_extendboolean提示词优化,默认 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": "z-image-turbo",
  "prompt": "A poster for a coffee shop with the title Good Morning",
  "n": 1,
  "size": "1024x1024",
  "providerOptions": {
    "prompt_extend": false
  }
}'
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": "z-image-turbo",
  "prompt": "A poster for a coffee shop with the title Good Morning",
  "n": 1,
  "size": "1024x1024",
  "providerOptions": {
    "prompt_extend": False
  }
},
)
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": "z-image-turbo",
  "prompt": "A poster for a coffee shop with the title Good Morning",
  "n": 1,
  "size": "1024x1024",
  "providerOptions": {
    "prompt_extend": false
  }
}),
});
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": "z-image-turbo",
  "prompt": "A poster for a coffee shop with the title Good Morning",
  "n": 1,
  "size": "1024x1024",
  "providerOptions": {
    "prompt_extend": false
  }
}`)
  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。参阅查询结果和计费说明。