Seedream(豆包)系列
字節跳動的豆包圖像模型,共三款,透過 OpenAI 相容介面 /v1/images/generations 呼叫,文生圖與改圖皆使用此端點。
模型選擇
- 支援 1K 尺寸
- 不支援組圖與 4k 預設檔位
- 支援組圖與 4K
- 最低 2K
- 支援組圖與 n 多張
- 最低 2K
volcengine/doubao-seedream-5.0-pro旗艦,支援 1K即時價格請參閱模型頁 。
文生圖
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1", timeout=600)
resp = client.images.generate(
model="volcengine/doubao-seedream-5.0-pro",
prompt="白色桌面上的一顆紅蘋果",
size="2560x1440",
)
with open("output.jpg", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))輸出格式固定為 JPEG,儲存時請使用 .jpg 副檔名。預設回傳 base64;傳入 "response_format": "url" 可改為回傳圖片連結。
尺寸(size)
1k 與 1024×1024 都會被拒絕。size 支援兩種寫法:
- 解析度檔位
1k、2k、4k(不區分大小寫):僅指定解析度,比例由模型依提示詞決定。實測 4.5 傳入2k時,輸出既有 2048×2048,也有 1664×2496。 - 精確寬高
寬x高:比例固定,須符合下表的像素範圍。
「—」表示本次未實測,請以火山方舟官方文件 為準。
常用的合法寬高(符合 4.5 與 5.0 Lite 的最低像素):
改圖與多圖參考
image 欄位,而非 input_images;不支援 /v1/images/edits。Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1", timeout=600)
with open("apple.jpg", "rb") as f:
ref = "data:image/jpeg;base64," + base64.b64encode(f.read()).decode()
resp = client.images.generate(
model="volcengine/doubao-seedream-5.0-pro",
prompt="把蘋果改成紫色,其他保持不變",
size="2k",
extra_body={"image": [ref]},
)
with open("apple_purple.jpg", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))image為陣列,每項為圖片 URL 或以data:image/...;base64,開頭的字串。多張參考圖依序放入陣列,並在提示詞中說明每張圖片的用途。input_images為 Qwen-Image 專用欄位,Seedream 不支援。- Seedream 不支援
/v1/images/edits,改圖請使用本節的image欄位。
組圖與多張
組圖範例:
{
"model": "volcengine/doubao-seedream-5.0-lite",
"prompt": "生成 3 張獨立的圖:同一隻狐狸分別在春天、夏天、秋天",
"size": "2k",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 }
}auto表示由模型決定生成張數,max_images僅為上限。實測相同請求下,4.5 將三格漫畫合成在一張圖中,只回傳 1 張。如需固定張數,請在提示詞中明確寫出「生成 N 張獨立的圖片」。- 每張圖片單獨計費,
usage.output_tokens為所有圖片的合計。
浮水印
實測透過 OfoxAI 呼叫時預設不帶浮水印,無需額外傳參。
耗時
實測 2K 約 12 至 40 秒,3 張組圖約 76 秒。用戶端逾時建議設定為 300 秒以上。
常見錯誤
錯誤原文末尾的 Request id: 0217… 為上游請求編號,聯絡技術支援時請與回應中的 request_id 一併提供。
錯誤原文
The parameter `size` specified in the request is not valid: image size must be at least 3686400 pixels.
The parameter `size` specified in the request are not valid: image area must be at least 921600 pixels.
The parameter `size` specified in the request is not valid: image size must be at most 16777216 pixels.
The parameter `size` specified in the request is not valid: the specified size is not supported for model doubao-seedream-4-5.
The parameter `size` specified in the request are not valid: must be 'WIDTHxHEIGHT' or a supported size preset.
The parameter `size` specified in the request is not valid: size must be one of 'WIDTHxHEIGHT', '1k', '2k', or '4k'.
The parameter `sequential_image_generation` specified in the request are not valid: the parameter `sequential_image_generation` is not supported by the current model.
The parameter `output_format` specified in the request is not valid: the parameter `output_format` is not supported by the current model.官方文件
官方文件描述的是直連火山方舟時的行為;透過 OfoxAI 呼叫時,以本頁實測結論為準。
常見問題
Seedream 出現 image size must be at least 3686400 pixels 該如何處理?
Seedream 4.5 與 5.0 Lite 的最低尺寸是 2K,即 3,686,400 像素,1024x1024 與 1k 都不符合要求。請改為 2k,或 2048x2048、2560x1440、1440x2560 等寬高。需要較小尺寸時請使用 5.0 Pro,它最低 921,600 像素(1280x720),也支援 1k。
Seedream 如何改圖?用 input_images 沒有效果?
Seedream 的參考圖欄位是 image(陣列,每項是圖片 URL 或 data:image 開頭的 base64),不是 input_images,input_images 是 Qwen-Image 的欄位。此外 Seedream 不支援 /v1/images/edits,改圖同樣使用 /v1/images/generations。
Seedream 組圖如何一次生成多張?
傳入 sequential_image_generation: "auto" 與 sequential_image_generation_options.max_images。auto 表示由模型決定張數,max_images 是上限,在提示詞中寫明「生成 N 張獨立的圖」會更穩定。5.0 Lite 與 4.5 支援,5.0 Pro 不支援。
Seedream 5.0 Pro 傳入 n 出現 sequential_image_generation is not supported?
5.0 Pro 不支援一次生成多張,n 與組圖參數都會回傳此錯誤。請刪除 n,如需多張,請並行發出多次請求。
Seedream 生成的圖片有浮水印嗎?
透過 OfoxAI 呼叫,實測預設不帶浮水印,無需額外傳參。
Seedream 能輸出 PNG 嗎?
不能,輸出固定為 JPEG。傳入 output_format 會回傳 400,刪除該參數即可。
Seedream 的 size 傳入 2k 為什麼比例不固定?
1k、2k、4k 只指定解析度,比例由模型依提示詞決定。需要固定比例請傳入精確寬高,如 2560x1440。