接口与能力

图片生成

用 OpenAI 兼容的图片接口生成和编辑图片,按张计费,和分组倍率无关。各模型价格见模型价格 · 图片模型。

可用分组
Seedream 生图(seedream-5-5)、ChatGPT 生图(gpt-image-2.6-sunburst 等 gpt-image 型号);Grok Imagine 生图只在 Grok 企业版 分组
接口地址
https://api.yuzuapi.com/v1/images/generations(生成)、/v1/images/edits(上传本地图片编辑)
密钥
生图分组的密钥只能生图,不能聊天;聊天和生图请各建一个密钥

Seedream 5.5

火山方舟官方渠道的豆包 Seedream 5.5:文生图、最多 10 张参考图融合、透明背景 PNG、图层拆分。模型填 seedream-5-5,官方 ID doubao-seedream-5-5-261028 也可以。默认不加水印,要水印时传 "watermark": true。

import os
from openai import OpenAI

# 用「Seedream 生图」分组的密钥;生成大图建议把超时设到 300 秒
client = OpenAI(base_url="https://api.yuzuapi.com/v1", api_key=os.environ["YUZU_API_KEY"], timeout=300)

img = client.images.generate(
    model="seedream-5-5",
    prompt="极简北欧风陶瓷手冲咖啡壶放在浅色橡木桌面,清晨柔和侧逆光,商业静物摄影",
    size="2K",                     # 1K / 1.5K / 2K / 3K,或精确像素如 2560x1440
    response_format="url",
)
print(img.data[0].url)             # 临时链接,约 24 小时内有效,请及时下载
curl --max-time 300 https://api.yuzuapi.com/v1/images/generations \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "seedream-5-5", "prompt": "a yuzu on a wooden table, soft morning light", "size": "16:9", "resolution": "2K"}'
const res = await fetch("https://api.yuzuapi.com/v1/images/generations", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.YUZU_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ model: "seedream-5-5", prompt: "a yuzu on a wooden table, soft morning light", size: "2K" }),
  signal: AbortSignal.timeout(300_000),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
const { data, usage } = await res.json();
console.log(data[0].url, usage);
参数说明
size三种写法:档位 1K / 1.5K / 2K / 3K;比例如 16:9(配合 resolution);精确像素如 2560x1440,最大 3840×2160
resolutionsize 写比例时用,取值 1K / 1.5K / 2K / 3K
image参考图,公网链接或 data:image/png;base64,…,最多 10 张(也兼容 image_urls)
output_formatpng(默认)或 jpeg
backgroundtransparent 输出透明 PNG(必须配 png),opaque 不透明
response_formaturl(默认,约 24 小时有效的临时链接)或 b64_json
参考图融合最多 10 张参考图,在提示词里写清楚「改什么、保留什么」
curl --max-time 300 https://api.yuzuapi.com/v1/images/generations \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-5-5",
    "prompt": "保留图1人物的面部、发型和服装,让人物戴上图2里的太阳镜,背景不变",
    "image": ["https://example.com/person.png", "https://example.com/sunglasses.png"],
    "size": "2K"
  }'
上传本地图片用 /v1/images/edits 直接上传文件,不用先传到图床
curl --max-time 300 https://api.yuzuapi.com/v1/images/edits \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -F "model=seedream-5-5" \
  -F "prompt=保留产品主体和瓶身文字,把背景换成浅灰色摄影棚" \
  -F "size=2K" \
  -F "image[]=@./product.png"
透明背景 PNG贴纸、图标、商品图,参考图不需要自带透明通道
curl --max-time 300 https://api.yuzuapi.com/v1/images/generations \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "seedream-5-5", "prompt": "一枚半透明冰蓝色玻璃小狐狸徽章贴纸,独立主体", "size": "2K", "output_format": "png", "background": "transparent"}'
图层拆分把一张图拆成 1 张底图 + 最多 99 个透明图层,并识别文字

用火山方舟原生接口 /api/v3/images/generations,必须恰好 1 张 PNG / JPEG 参考图,不能传 background,size 只能是 auto / 1K / 1.5K / 2K。

curl --max-time 600 https://api.yuzuapi.com/api/v3/images/generations \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5-5-261028",
    "prompt": "把海报里的标题文字、装饰图形和主体拆成独立图层,底图补全背景",
    "image": "https://example.com/poster.png",
    "size": "2K",
    "layer_decomposition": true,
    "layer_decomposition_options": {"max_images": 10, "text_recognition": true}
  }'

每个图层都按一张出图计费,再加 1 张参考图的费用。max_images(2–100,默认 30,含底图)决定最多拆几张,先用小的值试。拆层一般要 1–4 分钟,客户端超时请设到 600 秒。

返回的图片链接是临时的,一般 24 小时后失效,请及时下载。生成记录可以在控制台 创作记录 里查看和下载。生成失败不收费。

GPT Image

用 ChatGPT 生图 分组的密钥,按张计费,分辨率越高越贵。

import base64, os
from openai import OpenAI

client = OpenAI(base_url="https://api.yuzuapi.com/v1", api_key=os.environ["YUZU_API_KEY"])

img = client.images.generate(model="gpt-image-2.6-sunburst", prompt="一只在柚子树下打盹的橘猫,水彩风格", size="1024x1024")
open("out.png", "wb").write(base64.b64decode(img.data[0].b64_json))
curl https://api.yuzuapi.com/v1/images/generations \
  -H "Authorization: Bearer $YUZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-image-2.6-sunburst", "prompt": "a yuzu on a wooden table, studio light", "size": "1024x1024"}'

可用模型:gpt-image-2.6-sunburst、gpt-image-2.6-flare、gpt-image-2.5-sunburst、gpt-image-2.5-flare、gpt-image-2。size 支持 1024x1024、1536x1024 等常见尺寸,最长边超过 1024 按 2K、超过 2048 按 4K 计费。

在 Cherry Studio、Chatbox 等客户端里生图

支持 OpenAI 图片接口(/v1/images/generations)的客户端都能用。做法是单独加一个提供商给生图用:

字段填写
提供商类型OpenAI / OpenAI API 兼容
API 地址https://api.yuzuapi.com
API 密钥生图分组的密钥(Seedream 生图或 ChatGPT 生图)
模型手动添加 seedream-5-5 或 gpt-image-2.6-sunburst,类型选「图片生成」或「绘画」

Cherry Studio:在左侧 绘画 页选择上面加的提供商和模型,输入提示词生成。Chatbox:在 图片创作 里选择提供商和模型。各版本菜单名称可能略有不同;如果客户端只走聊天接口(/v1/chat/completions),就不能用来生图。

生图分组的密钥不能聊天,所以别把它填到聊天用的提供商里;聊天请用另一个分组的密钥。