Skip to Content
登入

從 ByteDance 的 API 遷移

將為 ByteDance 自家 API 撰寫的程式碼移轉到 Kerox:保留請求內容並加上一層包裝,更換主機與金鑰,再以 Kerox 的方式讀取結果。

加上 "format": "native" 後,ByteDance 模型會接受 ByteDance 自家的請求內容,因此原本傳送的參數都不必更動。需要調整的是:主機、金鑰、model 和回呼的位置,以及取得結果的方式。其他模型沒有這個選項,它們接受Kerox 的參數名稱,而 ByteDance 模型也同樣接受這些名稱。

需要修改的地方

在原本的 ByteDance 程式碼中在 Kerox 上
ByteDance 的端點POST https://api.kerox.ai/v1/tasks,圖片和影片都使用此端點
ByteDance 的 API 金鑰Kerox 金鑰:Authorization: Bearer $KEROX_API_KEY(快速入門)
model:ByteDance 的模型名稱model:Kerox 模型 ID,例如 bytedance/seedream-5.5(模型)
請求內容的其餘部分保持不變,放在 input 內,並在旁邊加上 "format": "native"
callback_urlwebhook_url,放在最上層,與 model 並列(Webhook)
回應中的結果回應會立即提供任務的 id;輪詢 GET /v1/tasks/{id} 或等待 Webhook,然後讀取 outputs 中的檔案(任務)

部分 ByteDance 參數的處理方式不同:

  • 接受但忽略:service_tier、priority、safety_identifier。包含這些參數的請求內容可照常運作;由於這些參數不會傳給模型,因此會使用 ByteDance 的預設值。
  • 已移動:callback_url 改為最上層的 webhook_url。
  • 請移除:execution_expires_after、response_format、stream。包含這些欄位的請求會被拒絕,並回傳 HTTP 400 invalid_request,param 會指出欄位名稱。

修改前後對照

圖片請求。移除 response_format;結果一律是 outputs 中的檔案 URL。

{
  "model": "<ByteDance model name>",
  "prompt": "a quiet coastal lighthouse at dusk",
  "size": "2K",
  "response_format": "url",
  "watermark": false
}

影片請求。callback_url 移到外層成為 webhook_url;service_tier 可以保留,但會被忽略。

{
  "model": "<ByteDance model name>",
  "content": [{ "type": "text", "text": "a red fox running through fresh snow" }],
  "ratio": "16:9",
  "resolution": "720p",
  "duration": 5,
  "service_tier": "default",
  "callback_url": "https://your-app.example.com/webhooks/kerox"
}

送出請求

送出影片請求的範例。各模型在此格式中接受的參數,請參閱 GET /v1/models/{id} 中的 input_schema,以及各自模型頁面中的 ByteDance 格式章節。

curl -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedance-2.5",
    "format": "native",
    "input": {
      "content": [
        { "type": "text", "text": "a red fox running through fresh snow" }
      ],
      "ratio": "16:9",
      "resolution": "720p",
      "duration": 5
    }
  }'

回應及後續流程與一般任務相同:請參閱任務與輪詢。

本頁內容

給 AI 智慧代理

本頁內容(Markdown 格式): /zh-hant/docs/migrate-from-bytedance.md

一次取得全部內容: /llms-full.txt