curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 },
"watermark": false
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {"max_images": 3},
"watermark": False
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 3,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '4K',
optimize_prompt_options: 'standard',
sequential_image_generation: 'auto',
sequential_image_generation_options: { max_images: 3 },
watermark: false
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "doubao-seedream-4-0",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Seedream-4.0
Seedream-4.0 圖像生成
使用 Seedream 4.0 模型生成高質量圖像
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 },
"watermark": false
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {"max_images": 3},
"watermark": False
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 3,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '4K',
optimize_prompt_options: 'standard',
sequential_image_generation: 'auto',
sequential_image_generation_options: { max_images: 3 },
watermark: false
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "doubao-seedream-4-0",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
- Seedream 4.0 高質量圖像生成模型
- 通過 model 參數選擇
doubao-seedream-4-0模型 - 支持文本到圖像生成
- 異步任務管理,通過任務 ID 查詢結果
重要變更:爲了更好的性能和成本控制,我們不再支持在
image_urls 中直接傳入 base64 圖片數據。請先使用 上傳圖片接口 上傳圖片,獲取 URL 後再調用本接口。Authorizations
string
必填
所有接口均需要使用 Bearer Token 進行認證獲取 API Key:訪問 API Key 管理頁面 獲取您的 API Key使用時在請求頭中添加:
Authorization: Bearer YOUR_API_KEY
Body
string
預設值:"doubao-seedream-4-0"
必填
圖像生成模型名稱示例:
"doubao-seedream-4-0"string
必填
圖像生成的文本描述最長 1000 個字符
string
預設值:"1:1"
圖像寬高比支持的寬高比:
1:1- 正方形(默認)4:3- 橫向 4:33:4- 豎向 3:416:9- 橫向寬屏9:16- 豎向長圖3:2- 橫向 3:22:3- 豎向 2:321:9- 超寬屏9:21- 超窄屏auto- 自動匹配參考圖像比例(需要提供image_urls)
integer
預設值:1
生成圖像的數量範圍:1-15(最少 1 張,最多 15 張)默認:1注意:
- 實際可生成的圖像數量受此參數和輸入參考圖像數量共同影響。參考圖像 + 生成圖像總數必須 ≤ 15
- 必須輸入純數字(如
1),不要加引號,否則會報錯
string[]
參考圖像 URL 列表,用於圖生圖或圖像編輯⚠️ 僅支持 URL 格式(不再支持 base64)
- 公開可訪問的圖像 URL(http:// 或 https://)
- 示例:
https://example.com/image.jpg - 可使用 上傳圖片接口 上傳本地圖片獲取 URL
- 最多 10 張圖片
- 圖像格式:jpeg, png
- 寬高比(寬/高)範圍:[1/3, 3]
- 寬度和高度(px)> 14
- 單張圖片大小:不超過 10MB
- 總像素:不超過 6000×6000 px
object
渠道特有參數,用於傳遞 Seedream 4.0 模型的高級配置
顯示 metadata 屬性
顯示 metadata 屬性
string
預設值:"2K"
圖像分辨率支持的分辨率:
1K- 基礎分辨率2K- 標準分辨率(默認)4K- 高清分辨率
| 分辨率 | 1:1 尺寸 | 16:9 尺寸 |
|---|---|---|
| 1K | 1024x1024 | 1280x720 |
| 2K | 2048x2048 | 2560x1440 |
| 4K | 4096x4096 | 5404x3040 |
object
提示詞優化選項屬性:
mode(字符串):優化模式standard:標準模式,生成質量更高,處理時間更長(默認)fast:快速模式,處理時間更短,質量一般
"optimize_prompt_options": { "mode": "standard" }
string
預設值:"disabled"
順序圖像生成模式(豆包專屬功能)控制是否生成多張圖像:
disabled:禁用順序模式,即使有多張參考圖像也只生成 1 張(默認)auto:啓用順序模式,可以生成多張圖像
- ✅ 設置
n: 3或使用sequential_image_generation: "auto"+max_images: 3 - ✅ 支持文生圖:僅提供文本提示詞,最多生成 15 張圖像
- ✅ 支持圖生圖:提供
image_urls,基於參考圖像生成多張圖像 - ⚠️ 當
n > 1時,會自動設置爲auto
- 輸入的參考圖數量 + 最終生成圖片數量 ≤ 15 張
object
順序圖像生成選項當
sequential_image_generation 設置爲 auto 時可用屬性:max_images(整數):指定生成的圖像數量,範圍:1-15
"sequential_image_generation_options": { "max_images": 3 }
boolean
預設值:true
是否爲生成的圖像添加水印
true:添加水印(默認)false:不添加水印
Response
string
任務唯一標識符,用於查詢任務狀態
string
對象類型,固定爲
generation.taskstring
使用的模型名稱
string
任務狀態
queued- 排隊等待處理in_progress- 處理中completed- 成功完成failed- 失敗
integer
任務進度百分比(0-100)
integer
任務創建時間戳(Unix 時間戳)
object
任務元數據
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": [
"https://example.com/panda.jpg"
],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 },
"watermark": false
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 1,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "2K"
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "doubao-seedream-4-0",
"prompt": "可愛的熊貓在竹林中玩耍",
"size": "1:1",
"n": 3,
"image_urls": ["https://example.com/panda.jpg"],
"metadata": {
"resolution": "4K",
"optimize_prompt_options": "standard",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {"max_images": 3},
"watermark": False
}
}
)
task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 1,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '2K'
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'doubao-seedream-4-0',
prompt: '可愛的熊貓在竹林中玩耍',
size: '1:1',
n: 3,
image_urls: ['https://example.com/panda.jpg'],
metadata: {
resolution: '4K',
optimize_prompt_options: 'standard',
sequential_image_generation: 'auto',
sequential_image_generation_options: { max_images: 3 },
watermark: false
}
})
});
const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "doubao-seedream-4-0",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
⌘I