跳至說明文件
本頁目錄

Seedream 5.0 Pro API

使用您的 Seevio API 金鑰生成圖片、編輯參考圖或將圖片分解為圖層。任務採非同步執行,請保存回傳的 taskId 並輪詢查詢端點或接收回呼通知。

POST https://api.seevio.ai/v1/images/generations

模型功能

功能支援的值
生成模式text-to-image, image-to-image, layer-decomposition
輸出解析度1K, 1.5K, 2K
長寬比1:1, 4:3, 3:4, 16:9, 9:16, 2:3, 3:2, 21:9
參考圖片公開可存取的 HTTPS PNG / JPEG / WebP 圖片 URL,每張上限 30 MB。文生圖不傳入圖片,圖生圖傳入 1–10 張,圖層分解則必須且只能傳入 1 張。
提示詞去除首尾空白後,提示詞長度須為 4–5000 個字元。僅在 layer-decomposition 模式下,prompt 可省略或留空。
輸出格式png, jpg

計費與額度

下方價格為每張回傳圖片的單價。一般生成預扣 1 張圖片的點數。圖層分解預扣 17 張圖片的點數,完成後依實際回傳數量(含底圖)結算,未使用的點數退回原餘額。失敗任務全額退款。

輸出解析度計費與額度
1K4 額度
1.5K4 額度
2K8 額度

以預設的 2K 解析度為例,圖層分解會先預扣 136 點。若最後產出 4 張圖片,實際扣款為 32 點,並退還 104 點。

不支持请求幂等。每次有效 POST 都会新建任务并预扣。提交结果不明确时请查询返回的 taskId,重新 POST 可能产生额外任务。

身分驗證

請至控制台建立 API 金鑰。完整的金鑰內容僅會顯示一次,請妥善保存在您的伺服器端,並在每次發送請求時,將其作為 Bearer 權杖(Token)帶入標頭。

基本 URL

https://api.seevio.ai
Authorization: Bearer sk_live_your_api_key
Content-Type: application/json

在執行這些程式碼範例之前,請先設定 SEEVIO_API_KEY 環境變數。JavaScript 範例將在您的 Node.js 伺服器端執行;Python 範例則使用 requests 套件。

請求主體

欄位類型必填說明與限制
model
string是

模型 ID。若要使用 Seedream 5.0 Pro,請將此欄位設為 seedream-5-0-pro。

callback_url
string否

用於接收完成和失敗 POST 回呼的公開 HTTPS 端點。不支援私有網路與 localhost。

範例: https://example.com/webhooks/seevio
input
object是

生成設定物件。文字生成圖片與圖片生成圖片模式下提示詞為必填;圖層分解模式下提示詞為選填。

輸入參數

欄位類型必填預設值說明與限制
input.prompt
string條件式必填—

去除首尾空白後,提示詞長度須為 4–5000 個字元。僅在 layer-decomposition 模式下,prompt 可省略或留空。

範例: A minimalist ceramic teapot on a stone pedestal, soft studio lighting
input.generation_type
string否text-to-image

使用 text-to-image 生成新圖片,使用 image-to-image 編輯參考圖,或使用 layer-decomposition 將單張圖片分解為可重複使用的元素。

支援的值
text-to-image | image-to-image | layer-decomposition
input.image_urls
string[]條件式必填[]

公開可存取的 HTTPS PNG / JPEG / WebP 圖片 URL,每張上限 30 MB。文生圖不傳入圖片,圖生圖傳入 1–10 張,圖層分解則必須且只能傳入 1 張。

範例: ["https://example.com/teapot.png"]
input.aspect_ratio
string否1:1

長寬比

支援的值
1:1 | 4:3 | 3:4 | 16:9 | 9:16 | 2:3 | 3:2 | 21:9
範例: 1:1
input.resolution
string否2K

文生圖與圖生圖支援 1K(基礎畫質)與 2K(高畫質)。圖層分解支援 1K、1.5K 與 2K。預設值:2K。

支援的值
1K | 1.5K | 2K
範例: 2K
input.output_format
string否png

要求的輸出格式。針對圖層分解,設定 png 會傳回 PNG 底圖,設定 jpg 則會傳回 JPEG 底圖。所有分離後的圖層一律以保留透明度的 PNG 格式傳回。

支援的值
png | jpg
範例: png

每次請求皆會建立一個任務。文字生成圖片與圖片生成圖片會傳回一張圖片;圖層分解則會傳回 1 至 17 張圖片(包含底圖)。執行圖層分解時,請勿傳送 aspect_ratio。

快速上手

提交此最簡請求並保存回傳的 taskId,接著使用下方的任務查詢範例。在「建立任務回應」中顯示的 credits 值為預先扣除(凍結)的額度。

curl --fail-with-body https://api.seevio.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEVIO_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "seedream-5-0-pro",
  "input": {
    "prompt": "A minimalist ceramic teapot on a stone pedestal, soft studio lighting",
    "aspect_ratio": "1:1",
    "resolution": "2K",
    "output_format": "png",
    "generation_type": "text-to-image"
  }
}'

建立任務的回傳範例

{
  "taskId": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "credits": 8
}

文生圖呼叫範例

使用您的 Seevio API 金鑰生成圖片、編輯參考圖或將圖片分解為圖層。任務採非同步執行,請保存回傳的 taskId 並輪詢查詢端點或接收回呼通知。

curl --fail-with-body https://api.seevio.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEVIO_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "seedream-5-0-pro",
  "input": {
    "prompt": "A minimalist ceramic teapot on a stone pedestal, soft studio lighting",
    "aspect_ratio": "1:1",
    "resolution": "2K",
    "output_format": "png",
    "generation_type": "text-to-image"
  }
}'

圖生圖呼叫範例

图生图时,将 generation_type 设为 image-to-image,并提供 image_urls,其他参数保持一致。

請將範例中的 example.com 媒體 URL 替換為您自己可公開存取的 HTTPS 檔案。範例 URL 僅用於展示請求格式,並非可下載的真實素材。

curl --fail-with-body https://api.seevio.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEVIO_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "seedream-5-0-pro",
  "input": {
    "prompt": "Change the teapot to matte sage green. Preserve its shape and the studio lighting.",
    "aspect_ratio": "1:1",
    "resolution": "2K",
    "output_format": "png",
    "generation_type": "image-to-image",
    "image_urls": [
      "https://example.com/teapot.png"
    ]
  }
}'

圖層分解功能

請將 generation_type 設定為 layer-decomposition,並提供剛好一個圖片 URL。請省略 aspect_ratio。output_format 僅控制底圖格式。分離後的圖層一律以保留透明度的 PNG 格式傳回。請保存 data.results 中的每個 URL。

curl --fail-with-body https://api.seevio.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEVIO_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "seedream-5-0-pro",
  "input": {
    "generation_type": "layer-decomposition",
    "image_urls": [
      "https://example.com/teapot.png"
    ],
    "resolution": "2K",
    "output_format": "png"
  }
}'

圖層分解可能在 data.results 中回傳多個圖片 URL,包含底圖及分離出的圖層。每個 URL 指向一張獨立圖片。結果數量隨任務而變(共 1–17 張);請處理整個陣列,而非僅讀取 data.results[0]。任務完成後的查詢回應與完成通知 Webhook 均包含此陣列。初始建立任務回應包含 taskId 與預扣點數,不含圖片 URL。

建立任務的回傳範例

{
  "taskId": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "credits": 136
}

圖層分解完成:多圖層 URL 回應範例

此範例展示了 4 張輸出圖片:包含 1 張底圖與 3 個圖層。您的任務實際產出數量可能不同。在 2K 解析度下,credits 顯示為這 4 張圖片的最終結算費用;原本預扣 17 張的剩餘點數已自動退還。

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171200,
  "model": "seedream-5-0-pro",
  "credits": 32,
  "failed_code": null,
  "status": "completed",
  "billing_status": "charged",
  "failed_reason": null,
  "data": {
    "results": [
      "https://cdn.seevio.ai/api/images/example/base.png",
      "https://cdn.seevio.ai/api/images/example/layer-1.png",
      "https://cdn.seevio.ai/api/images/example/layer-2.png",
      "https://cdn.seevio.ai/api/images/example/layer-3.png"
    ],
    "image_expires_at": "2026-10-12T00:00:00.000Z",
    "processing_time": 12
  }
}

請務必處理所有回傳的圖片連結

const response = await fetch(
  "https://api.seevio.ai/v1/tasks/TASK_ID",
  { headers: { Authorization: `Bearer ${process.env.SEEVIO_API_KEY}` } }
);
if (!response.ok) throw new Error(await response.text());
const task = await response.json();

if (task.status === "completed") {
  // Process every returned image, including the base image.
  // The number of URLs varies; do not read only results[0].
  for (const [index, imageUrl] of task.data.results.entries()) {
    console.log({ taskId: task.id, index, imageUrl });
    // Download or store this image in your application.
  }
} else if (task.status === "failed") {
  throw new Error(task.failed_reason || "Image generation failed.");
}
// If queued or generating, poll again after at least 5 seconds.

查詢任務

GET https://api.seevio.ai/v1/tasks/{taskId}

請將範例中的 ID 替換為建立任務時回傳的 taskId。查詢功能僅能存取該 API 金鑰擁有者建立的任務;存取無權限或不存在的 ID 會回傳 HTTP 404。

建議每 10–20 秒輪詢一次,若收到 HTTP 429 則請放慢頻率(Backoff),並在狀態轉為 completed 或 failed 時停止。生產環境建議優先採用 Webhook。下方的每個程式碼範例僅執行單次查詢。

curl --fail-with-body https://api.seevio.ai/v1/tasks/3f2aK9mR7xQp4TnZ8bLc6YwH \
  -H "Authorization: Bearer $SEEVIO_API_KEY"
狀態允许值与要求
queued已接收並等待提交處理。
generating圖片正在生成中。
completed生成成功。請在過期前下載 data.results 中的圖片。
failed生成失敗。請檢查 failed_reason 和 billing_status。
字段類型允许值与要求
idstring任務識別碼。即建立任務回應中的 taskId。
created_atnumber任務建立時間(Unix 時間戳記,秒)。
modelstring執行此任務所使用的公開模型 ID。
billing_statusstring帳務狀態:reserved(已預扣)、charged(已扣款)、refunded(已退款)或 refund_failed(退款失敗)。
creditsnumber建立任務回應與進行中的任務會顯示預扣點數。任務完成後,credits 將更新為實際扣款金額(多預扣的點數已自動退回)。失敗的任務則維持顯示初始預扣金額。
failed_reasonstring | null任務失敗時的原因說明;成功時為 null。失敗的查詢回應中會省略 data 欄位。
failed_codestring | null錯誤碼。具體錯誤說明詳見 failed_reason。
dataobject僅在未失敗的任務查詢中出現。包含輸出成果與處理細節。
data.resultsstring[]所有輸出的圖片 URL,包含圖層分解的底圖。任務完成前與過期後此陣列為空。
data.image_expires_atstring | null圖片到期時間,ISO 8601 格式;尚未產生時為 null。
data.processing_timenumber | null若有提供,則為任務處理時間(秒),否則為 null。

排隊中

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171200,
  "model": "seedream-5-0-pro",
  "credits": 8,
  "failed_code": null,
  "status": "queued",
  "billing_status": "reserved",
  "failed_reason": null,
  "data": {
    "results": [],
    "image_expires_at": null,
    "processing_time": null
  }
}

已完成

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171200,
  "model": "seedream-5-0-pro",
  "credits": 8,
  "failed_code": null,
  "status": "completed",
  "billing_status": "charged",
  "failed_reason": null,
  "data": {
    "results": [
      "https://cdn.seevio.ai/api/images/example.png"
    ],
    "image_expires_at": "2026-10-12T00:00:00.000Z",
    "processing_time": 12
  }
}

失敗

當查詢狀態顯示 status=failed 時,代表生成失敗。請參閱 failed_reason 瞭解失敗原因,並查看 billing_status 確認退款結果。在此範例中,refunded 表示額度已退還。credits 仍會顯示原先預扣的額度,且回應中不會包含 data 資料。

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171200,
  "model": "seedream-5-0-pro",
  "credits": 8,
  "failed_code": "400",
  "status": "failed",
  "billing_status": "refunded",
  "failed_reason": "The input or output was flagged as sensitive. Please try again with different inputs."
}

结果转存后 30 天内可获取结果链接,过期后 results 为空。

Webhook

在建立任務的請求中設定 callback_url,即可在任務完成或失敗時接收 JSON POST 請求。您的伺服器必須在 15 秒內回傳 2xx 回應。發送失敗的回呼會進行重試;請根據任務 ID 進行等冪(Idempotent)處理,以防重複發送。

您的回呼端點必須接受含有 JSON 請求主體的 POST 請求 (Content-Type: application/json)。

建立包含回呼設定的任務

curl --fail-with-body https://api.seevio.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEVIO_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "seedream-5-0-pro",
  "input": {
    "prompt": "A minimalist ceramic teapot on a stone pedestal, soft studio lighting",
    "aspect_ratio": "1:1",
    "resolution": "2K",
    "output_format": "png",
    "generation_type": "text-to-image"
  },
  "callback_url": "https://example.com/webhooks/seevio"
}'

回呼使用任務查詢回應的資料結構;已退款的失敗通知額外包含頂層 credits_refunded。使用 id 關聯任務,使用 status 判斷 completed 或 failed。通知可能重複,請按 id 和 status 做冪等處理。回呼不簽名,請透過驗證身分的查詢介面核實。通知失敗不會對成功任務退款。

任務完成:成功回呼的承載資料

created_at 為回呼事件建立時間,task_created_at 為任務建立時間,均為 Unix 秒級時間戳記。範例展示建議使用的欄位,實際回應可能包含額外欄位。

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171212,
  "model": "seedream-5-0-pro",
  "credits": 8,
  "failed_code": null,
  "status": "completed",
  "billing_status": "charged",
  "failed_reason": null,
  "data": {
    "results": [
      "https://cdn.seevio.ai/api/images/example.png"
    ],
    "image_expires_at": "2026-10-12T00:00:00.000Z",
    "processing_time": 12
  },
  "task_created_at": 1789171200
}

任務失敗:失敗回呼的承載資料

{
  "id": "3f2aK9mR7xQp4TnZ8bLc6YwH",
  "created_at": 1789171212,
  "model": "seedream-5-0-pro",
  "credits": 8,
  "failed_code": "400",
  "status": "failed",
  "billing_status": "refunded",
  "failed_reason": "The input or output was flagged as sensitive. Please try again with different inputs.",
  "task_created_at": 1789171200,
  "credits_refunded": 8
}

接收端範例

export async function POST(request: Request) {
  const callbackData = await request.json();

  if (callbackData.status === "completed") {
    const imageUrls = callbackData.data.results;
    // Save the image URLs and mark this task as completed in your application.
    console.log(callbackData.id, imageUrls);
  }

  if (callbackData.status === "failed") {
    const { failed_reason, credits_refunded } = callbackData;
    // Record the failure reason and refunded credits for this task.
    console.error(callbackData.id, failed_reason, credits_refunded);
  }

  return new Response(null, { status: 200 });
}

此 Next.js 範例可讀取 JSON 回呼主體,並直接處理已完成與失敗的任務。請為您的應用程式加入持續性與任務 ID 去重功能;並在確認回呼前,將耗時較長的工作排入佇列。

錯誤處理

HTTP 錯誤會包含一個 error 物件,內有 code(錯誤碼)和 message(錯誤訊息)。即使任務成功建立,後續仍可能生成失敗;請持續查詢任務狀態或處理失敗回呼。

{
  "error": {
    "code": "invalid_request",
    "message": "input.prompt is required."
  }
}
HTTP欄位建議處理方法
400invalid_request
請在重試前修正 JSON 格式、缺少的提示詞、無效的參數範圍或媒體 URL。
401invalid_api_key
請檢查 Bearer 權杖(Token)以及 API 金鑰是否處於啟用狀態。
402insufficient_credits
請儲值額度或降低任務成本。回應中可能會顯示所需的額度與目前可用額度。
403forbidden
請檢查錯誤訊息中說明的帳戶權限限制。
404not_found
請檢查任務 ID 是否正確,以及該金鑰是否屬於建立該任務的使用者。
429rate_limited
請在 Retry-After 指定的間隔時間過後再重試。
500internal_error
請檢查錯誤訊息和 API 日誌。請謹慎重試;重複送出建立請求可能會產生新的計費任務。

錯誤使用 error.code 與 error.message 表示:400 invalid_request、401 invalid_api_key、402 insufficient_credits、403 forbidden、404 not_found、429 rate_limited、500 internal_error。其中 402 insufficient_credits 錯誤代表您的可用點數不足以執行此請求。

速率限制

建立任務:預設情況下,每個 API 金鑰每分鐘最多允許 100 次請求。目前不提供自訂速率限制。

查詢任務:預設情況下,每個 API 金鑰每分鐘最多允許 120 次請求。查詢請求與任務建立請求為分開計算。

圖片與影片的建立請求共用同一個 API Key 的速率限制額度。

回傳 HTTP 429 時,建立任務會包含 Retry-After: 60,查詢任務會包含 Retry-After: 5。請使用退避演算法(Backoff),避免過於頻繁地進行輪詢。

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
  "error": {
    "code": "rate_limited",
    "message": "Rate limit exceeded."
  }
}