跳转到主要内容
POST
https://api.aisa.one/v1
/
chat
/
completions
curl --request POST \
  --url https://api.aisa.one/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "wan2.7-image",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "A cute red panda, ultra-detailed, cinematic lighting"
        }
      ]
    }
  ],
  "n": 1
}
'
{
  "id": "chatcmpl-fcc86dfd-9424-9523-b0bd-cdf07383bee2",
  "object": "chat.completion",
  "created": 1776495713,
  "model": "wan2.7-image",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": [
          {
            "type": "image",
            "image": "https://cdn.aisa.one/images/wan2.7/20260418-abc.png"
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 104,
    "completion_tokens": 8,
    "total_tokens": 112
  }
}
Wan 2.7 图像模型通过 Chat Completions 端点提供,而不是 OpenAI 风格的 /v1/images/generations 路径。请发送标准聊天请求,并使用包含文本提示词的多模态 content 数组;AIsa 会在 choices[].message.content[] 中以 {type: "image"} 部分返回生成的图像。
正在查找 Seedream(seedream-4-5-251128)?它使用不同的路由——/v1/images/generations。兼容 Gemini 的 generateContent 请求使用 /v1beta/models/{model}:generateContent。本页仅介绍 Wan 2.7 系列

支持的模型

模型每张图像费用典型用途
wan2.7-image$0.030快速、通用的图像生成
wan2.7-image-pro$0.075更高保真度;还支持通过独立流程进行图生视频

请求

请求架构与你已用于文本的 POST /v1/chat/completions 相同——唯一的区别是传入的模型以及 content 的结构。 关键规则:messages[].content 必须是带类型部分组成的数组。传入普通字符串会返回 400 invalid_parameter_error,错误消息为 "Input should be a valid list: messages[*].content"
curl -sS -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-image",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "A cute red panda, ultra-detailed, cinematic lighting" }
        ]
      }
    ],
    "n": 1
  }'
from openai import OpenAI

client = OpenAI(base_url="https://api.aisa.one/v1", api_key="sk-aisa-...")

resp = client.chat.completions.create(
    model="wan2.7-image",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "A cute red panda, ultra-detailed, cinematic lighting"}
            ],
        }
    ],
    n=1,
)

# Pull image URLs out of the response
for choice in resp.choices:
    for part in choice.message.content:
        if part["type"] == "image":
            print(part["image"])
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.aisa.one/v1",
  apiKey: process.env.AISA_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "wan2.7-image",
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "A cute red panda, ultra-detailed, cinematic lighting" },
      ] as any,
    },
  ],
  n: 1,
});

const urls = resp.choices
  .flatMap((c) => (c.message.content as any[]))
  .filter((p) => p.type === "image")
  .map((p) => p.image);

请求字段

字段类型必填说明
modelstringwan2.7-imagewan2.7-image-pro
messages[].rolestring提示词轮次使用 user
messages[].contentarray必须是数组,不能是字符串
messages[].content[].typestring提示词部分使用 text;图生图输入使用 image_url
messages[].content[].textstringtype=text提示词
messages[].content[].image_url.urlstringtype=image_url参考图像 URL
ninteger图像数量。wan2.7-image默认值为 4;传入 1 可节省费用

响应结构

{
  "id": "chatcmpl-fcc86dfd-...",
  "object": "chat.completion",
  "created": 1776495713,
  "model": "wan2.7-image",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": [
          { "type": "image", "image": "https://cdn.aisa.one/images/wan2.7/..." }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 104,
    "completion_tokens": 8,
    "total_tokens": 112
  }
}
  • **每张图像对应一个 choice。**如果 n=4choices 中会有 4 个条目。
  • 每个 choice.message.content 都是一个数组,其中包含一个 { "type": "image", "image": "..." } 部分。
  • 根据工作区配置,image 是短期有效的 URL(请尽快下载)或 base64 数据。
  • usage.total_tokens 反映请求封装产生的少量词元开销——计费按图像计算,费率见上表,而不是按词元计算。

图生图

content 数组开头添加一个 image_url 部分,并在其后添加文本指令:
{
  "model": "wan2.7-image-pro",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "image_url", "image_url": { "url": "https://example.com/reference.jpg" } },
        { "type": "text", "text": "Transform into an oil painting in the style of Van Gogh" }
      ]
    }
  ],
  "n": 1
}

为什么调试台显示 Chat Completions 路径

调试台发送的正是标准 OpenAI Chat 端点所使用的 POST /v1/chat/completions 请求——只是针对图像调整了 modelcontent 的结构。现有兼容 OpenAI 的 SDK 代码无需修改;只需替换模型和 content 结构。

常见 4xx 原因

  • 400 invalid_parameter_error — Input should be a valid list: messages[*].content——content 被作为字符串传入;请将其包装为带类型部分组成的数组。
  • 引用 messages400——你发送了 Gemini 风格的 contents/parts。Wan 模型应使用 messages 和 OpenAI 多模态部分。
  • /v1/images/generations 上的 404 openai_error——端点错误。Wan 模型不会通过该路径路由。
  • 500 model_not_found——你的工作区尚未配置 Wan 系列。请联系支持团队。
更多信息请参阅错误代码速率限制

相关内容

OpenAI Chat

与文本模型使用相同的端点。

Gemini generateContent

兼容 Gemini 的 generateContent 端点。

媒体生成技能

封装图像和视频生成的 Agent 技能。

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
model
enum<string>
必填

图像生成模型。wan2.7-image($0.030/张图像)用于标准质量,wan2.7-image-pro($0.075/张图像)用于更高保真度。

可用选项:
wan2.7-image,
wan2.7-image-pro
messages
object[]
必填

对话消息。图像提示词应放在最后一条用户消息的 content 数组中,并以 {type: "text"} 部分的形式提供。

n
integer
默认值:4

要生成的图像数量。wan2.7-image 默认返回 4 张;传入 1 可节省成本。

必填范围: 1 <= x <= 4

响应

已生成的图像。以 Chat Completion 形式返回,图像位于 message.content[] 的图像部分中。

id
string
示例:

"chatcmpl-fcc86dfd-9424-9523-b0bd-cdf07383bee2"

object
string
示例:

"chat.completion"

created
integer
示例:

1776495713

model
string
示例:

"wan2.7-image"

choices
object[]

每张生成的图像对应一个条目。

usage
object