Developer Docs

API Documentation Center

The documentation content stays aligned with the API project source, while the layout is refit to match the Seedance2.5 website experience.

Developer Docs
Seedance2.5 API Documentation
Go to Pricing

AiVideoAPI Documentation AiVideoAPI 平臺接口文檔

Welcome to the AiVideoAPI Platform. We provide enterprise-level multimodal video generation capabilities, including Text-to-Video, Image-to-Video, and Video-to-Video editing with audio support.

歡迎使用 AiVideoAPI 平臺。我們提供企業級的多模態視頻生成能力,支持文生視頻、圖生視頻、視頻編輯及擴展(可附帶音頻輸入)。

Base URL:基礎請求地址: https://api.sdapi.ai/api/v3

2. Authentication2. 接口鑑權

All API requests must include your platform-issued API Key in the HTTP Authorization header.

所有接口請求必須在請求頭 Authorization 中攜帶本平臺下發的 API Key(以 sk- 開頭)。

Authorization: Bearer sk-your-api-key-here

3. Pricing3. 計費說明

Cost is calculated based on token consumption. The token count is determined by output video duration, resolution, and frame rate.

費用按 Token 消耗計算。Token 數量由輸入視頻時長、輸出視頻時長、分辨率及幀率綜合決定。純文本/圖片/音頻輸入不計費,僅按最終生成的視頻計費。

  • Text/Image-to-Video: Billed at standard generation rates.文/圖生視頻: 按基礎生成費率扣費。
  • Video-to-Video: Includes a minimum token limit.視頻生視頻: 按視頻編輯費率扣費,包含最低 Token 消耗限制。

注:您的實際扣費將基於模型使用費率計算,任務完成(completed)時實時從餘額扣除。

4. Supported Models4. 支持的模型

Model Name模型名稱 Description說明
AiVideoMax Highest generation quality, corresponds to ByteDance's dreamina-seedance-2-0 model. Recommended for scenarios with extreme visual requirements.最高生成質量,對應字節跳動官方 dreamina-seedance-2-0 模型。推薦用於對畫面要求極高的場景。
AiVideoMin Balances cost and generation speed, corresponds to ByteDance's dreamina-seedance-2-0-fast model. Extremely cost-effective.平衡了成本與生成速度,對應字節跳動官方 dreamina-seedance-2-0-fast 模型。性價比極高。
AiVideoMini Lightweight low-cost model, corresponds to ByteDance's dreamina-seedance-2-0-mini model. Supports 480p and 720p output.輕量低成本模型,對應字節跳動官方 dreamina-seedance-2-0-mini 模型。支持 480p 與 720p 輸出。

5. Create Generation Task5. 創建生成任務

POST /contents/generations/tasks

Submit a video generation task. This is an asynchronous API.

提交視頻生成任務。此接口爲異步接口,返回任務 ID,需通過查詢接口獲取最終視頻。

Request Body Parameters請求體參數 (Body)
Parameter參數名 Type類型 Required必填 Description說明
model string Yes Model name (e.g., AiVideoMax)模型名稱(如 AiVideoMax
content array Yes Multimodal inputs. Array of text, image, video, and audio objects. 多模態輸入內容數組,支持文本、圖片、視頻、音頻的組合。
generate_audio boolean No Default false. Generates audio along with video.默認 false。是否隨視頻生成配套音頻。
duration integer No Generated video duration in seconds. Range: [4, 15] or -1 (auto). Default 5.生成視頻時長(秒)。範圍: [4, 15] 或 -1 (模型自適應)。默認 5 秒。
resolution string No Video resolution. Options: 4k, 1080p, 720p, 480p. 4k is only supported by AiVideoMax and AiVideoMaxNF; AiVideoMini and AiVideoMiniNF support 480p / 720p only. Default is 720p.視頻分辨率。可選值:4k, 1080p, 720p, 480p。其中 4k 僅支持 AiVideoMaxAiVideoMaxNFAiVideoMiniAiVideoMiniNF 僅支持 480p / 720p。默認爲 720p
ratio string No Aspect ratio (e.g., "16:9", "9:16", "1:1", "adaptive"). Default is "adaptive".視頻比例,例如 "16:9", "9:16", "1:1", "adaptive"。默認爲 "adaptive" (自適應)。
Content Array Object TypesContent 數組對象說明
  • 文本 (text): {"type": "text", "text": "提示詞描述"}
  • 圖片 (image_url): {"type": "image_url", "image_url": {"url": "圖片鏈接 或 asset://<Asset_Id>"}, "role": "reference_image"} (最多9張)
  • 視頻 (video_url): {"type": "video_url", "video_url": {"url": "視頻鏈接 或 asset://<Asset_Id>"}, "role": "reference_video"} (最多3個,總長不超15s)
  • 音頻 (audio_url): {"type": "audio_url", "audio_url": {"url": "音頻鏈接 或 asset://<Asset_Id>"}, "role": "reference_audio"} (必須配合圖/視頻使用)
  • Text: {"type": "text", "text": "prompt"}
  • Image: {"type": "image_url", "image_url": {"url": "URL or asset://<Asset_Id>"}, "role": "reference_image"} (Max 9)
  • Video: {"type": "video_url", "video_url": {"url": "URL or asset://<Asset_Id>"}, "role": "reference_video"} (Max 3)
  • Audio: {"type": "audio_url", "audio_url": {"url": "URL or asset://<Asset_Id>"}, "role": "reference_audio"}
Example: Text to Video示例 1:文生視頻 (Text to Video)
curl -X POST "https://api.sdapi.ai/api/v3/contents/generations/tasks" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
    "model": "AiVideoMax",
    "duration": 5,
    "ratio": "16:9",
    "content": [
        {
            "type": "text",
            "text": "A cute cat walking gracefully on the street, cinematic lighting, 4k."
        }
    ]
}'
Example: Multimodal Video Edit示例 2:多模態視頻編輯 (視頻+圖片+文本)
curl -X POST "https://api.sdapi.ai/api/v3/contents/generations/tasks" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
    "model": "AiVideoMin",
    "generate_audio": true,
    "content": [
        {
            "type": "text",
            "text": "The cat from [Image1] replaces the person in [Video1], walking identically."
        },
        {
            "type": "video_url",
            "video_url": { "url": "https://example.com/reference_video.mp4" },
            "role": "reference_video"
        },
        {
            "type": "image_url",
            "image_url": { "url": "https://example.com/cat_image.png" },
            "role": "reference_image"
        }
    ]
}'
Response Example響應示例
{
    "code": 0,
    "msg": "Success",
    "data": {
        "id": "cgt-2026123456789"
    }
}

6. Query Task6. 查詢任務狀態

GET /contents/generations/tasks/{task_id}

Poll this endpoint every few seconds to check the task status. Download the video once status is completed.

通過返回的 Task ID 輪詢此接口獲取任務狀態。狀態爲 completed 時,即可獲取生成的視頻鏈接(請在24小時內下載保存)。

Status Values任務狀態說明 (status)
Status狀態值 Description說明
queued Task is queued, waiting for resources.任務排隊中,等待分配計算資源。
pending Task is accepted and pending execution.任務已被接收,準備開始執行。
running Task is currently running.任務正在執行/生成中。
completed Task completed successfully. Video URL is available in content.任務執行成功。可在 content 中獲取視頻鏈接。
failed Task failed. Check error object for details.任務執行失敗。具體原因請查看返回的 error 字段。
Response Example (Completed)響應示例 (任務完成)
{
    "code": 0,
    "msg": "Success",
    "data": {
        "id": "cgt-2026123456789",
        "status": "completed",
        "content": [
            {
                "type": "video_url",
                "video_url": {
                    "url": "https://generation-result-url.mp4"
                }
            }
        ]
    },
    "usage": {
        "completion_tokens": 10240,
        "total_tokens": 10240
    }
}

7. List Tasks7. 獲取任務列表

GET /contents/generations/tasks?page_num=1&page_size=10

Retrieve a list of your historical generation tasks.

分頁獲取當前 API Key 提交的歷史視頻生成任務記錄。

8. Assets API8. 數字資產 (Assets API)

We provide a unified interface for all Assets API operations. You can use your standard API Key (Bearer Token) to interact with digital assets.

我們爲數字資產 (Assets API) 提供了統一的調用接口。您可以使用現有的 API Key (Bearer Token) 即可管理數字資產。這些資產(圖片、音頻、視頻)的 ID 可直接用於生成視頻時的素材引用。

Core Concepts & Constraints核心概念與上傳限制
  • Asset Group (資產組): 必須先創建資產組,再在組內創建具體資產。通常用於將同一角色的多張參考圖歸爲一組。
  • Asset (資產): 具體的圖片、視頻或音頻。上傳後需經過模型預處理,狀態變爲 Active 後才能在生成視頻時使用。
    狀態說明 (Status):
    • Processing: 資產正在預處理中,暫不可用。
    • Active: 資產已處理完成,可用於視頻生成。
    • Failed: 資產處理失敗。
  • 最佳實踐: 建議將面部特寫、全身圖、服裝細節分開上傳,不要拼接到一張圖裏,否則可能導致人臉識別失敗。(詳見下方最佳實踐示例)
  • 文件限制:
    • 圖片: jpeg/png/webp 等,寬高比 0.4~2.5,分辨率 300~6000px,小於 30MB。
    • 視頻: mp4/mov,時長 2~15秒,小於 50MB,幀率 24~60fps。
  • 頻率限制: CreateAsset (上傳素材) 限制 300 QPM(次/分鐘),其餘接口限制 10 QPS(次/秒)。
  • Asset Group: Create a group first, then add assets to it. Useful for grouping multiple references of the same character.
  • Asset: Image, video, or audio. Must be in Active status to be used.
  • Best Practice: Separate facial close-ups and outfit details into different images. Do not collage them. (See best practice examples below)
  • Constraints:
    • Image: jpeg/png/webp, ratio 0.4-2.5, 300-6000px, < 30MB.
    • Video: mp4/mov, 2-15s, < 50MB, 24-60fps.
  • Rate Limits: CreateAsset is 300 QPM. Others are 10 QPS.
API Endpoints Reference具體接口列表與參數

POST /contents/assets/{action}

所有資產相關接口通過統一的路由調用,請在 {action} 中填入對應的接口名,並將參數放入 JSON Body 中。

All asset endpoints use a unified route. Replace {action} with the target endpoint name and provide parameters in the JSON Body.

1. CreateAssetGroup 創建資產組Create Group

爲同一角色的多張參考圖創建一個管理組。Create a management group for multiple references of the same character.

ParameterTypeRequiredDescription
NamestringYes資產組名稱 (最長64字符)Group name (max 64 chars)
GroupTypestringNo類型,默認傳 AIGCType, pass AIGC
ProjectNamestringNo默認傳 defaultDefault is default
Response: {"Id": "group-..."}
2. CreateAsset 上傳創建資產Upload Asset

上傳素材到指定的資產組。注意:此接口異步處理,上傳後必須通過 GetAsset 查詢狀態。Upload media to a group. Note: Asynchronous processing. Use GetAsset to poll status.

ParameterTypeRequiredDescription
GroupIdstringYes資產組 IDAsset Group ID
URLstringYes素材的公網下載鏈接 (不支持 Base64)Public URL of media (Base64 not supported)
AssetTypestringYesImage / Video / AudioImage / Video / Audio
ProjectNamestringNo默認傳 defaultDefault is default
Response: {"Id": "Asset-..."}
3. GetAsset 查詢資產狀態Get Asset Status
ParameterTypeRequiredDescription
IdstringYes資產 IDAsset ID
Response Status: Active (可用), Processing (處理中), Failed (失敗)
4. ListAssets & ListAssetGroups 列表查詢List Queries

用於按條件過濾和分頁查詢資產或資產組。Filter and paginate assets or groups.

ParameterTypeRequiredDescription
Filter.GroupTypestringYesAIGCPass AIGC
Filter.GroupIdsarrayNo按資產組 ID 過濾 (ListAssets用)Filter by Group IDs
Filter.StatusesarrayNo["Active"]e.g. ["Active"]
PageNumber / PageSizeintYes分頁參數 (頁碼從 1 開始, 每頁最大 100)Pagination (Start at 1, max 100)

其他支持的接口: UpdateAssetGroup (更新組名), UpdateAsset (更新資產名), DeleteAsset (刪除資產)。

Other Supported Endpoints: UpdateAssetGroup, UpdateAsset, DeleteAsset.

Workflow & Code Example (Python)完整工作流與代碼示例 (Python)

1. 創建組 -> 2. 上傳素材 -> 3. 輪詢等待 Active -> 4. 填入生成視頻接口中

1. Create Group -> 2. Upload Asset -> 3. Poll until Active -> 4. Use in Video Generation

import requests
import time

API_KEY = "sk-your-api-key"
BASE_URL = "https://api.sdapi.ai/api/v3/contents/assets"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

def create_asset_and_wait():
    # 1. Create Group (Skip if you already have one)
    group_id = "group-xxxx" 
    
    # 2. Create Asset
    create_payload = {
        "GroupId": group_id,
        "URL": "https://example.com/your-image.jpg",
        "AssetType": "Image"
    }
    print("Uploading asset...")
    res = requests.post(f"{BASE_URL}/CreateAsset", headers=HEADERS, json=create_payload).json()
    asset_id = res.get("Result", {}).get("Id") or res.get("Id")
    
    # 3. Poll for Status
    print(f"Asset created: {asset_id}. Waiting for processing...")
    while True:
        status_res = requests.post(f"{BASE_URL}/GetAsset", headers=HEADERS, json={"Id": asset_id}).json()
        status = status_res.get("Result", {}).get("Status") or status_res.get("Status")
        
        if status == "Active":
            print("Asset is ready to use!")
            break
        elif status == "Failed":
            print("Asset processing failed.")
            break
        time.sleep(3)

create_asset_and_wait()
Best Practice - Uploading Private Assets最佳實踐 - 上傳私有資產

在上傳人物資產時,將目標人臉參考、全身參考和細節參考拼接到一張圖片中,會使每個參考區域過小。這增加了模型的識別難度,可能導致生成的角色與上傳的資產不匹配。在某些情況下,甚至可能導致非公衆人物人臉被誤判爲公衆人物,觸發風控攔截。

When uploading assets, combining the target face reference, full-body reference, and detail references into a single image may make each reference region too small. This increases the model's recognition difficulty and can lead to mismatches between the generated character and the uploaded asset. In some cases, it may also cause a non-celebrity face to be misclassified as a celebrity look-alike, triggering risk-control blocking.

應該Should

提供背景參考圖、角色造型的三視圖、角色面部中性表情特寫,分開爲多張圖片,並配合提示詞。

Provide background reference image, three-view images of the character's styling, close-up image of the character's face with a neutral expression as separate images, along with prompts.

  • Image 1: Background
  • Image 2: Three-view-image (Styling)
  • Image 3: Facial close-up
不應該Shouldn't

提供背景參考圖、角色造型的三視圖,但缺少面部特寫,或者將所有內容拼接到一張圖中

Provide background reference image, three-view images of the character's styling, but missing facial close-up, or combining all into a single collage image.

  • Image 1: Background
  • Image 2: Three-view-image (Missing face)
多圖生成提示詞示例 (Prompt Example)Prompt Example with Multiple Images

Character A (styling reference: Image 2; facial features must strictly match Image 3) walks hand in hand along a garden path.

9. Query Balance9. 查詢餘額

GET /user/balance

Check your current available account balance.

查詢當前賬戶的可用餘額。

Response Example響應示例
{
    "code": 0,
    "msg": "Success",
    "data": {
        "balance": 100.50,
        "currency": "USD"
    }
}

10. Spending Records10. 扣費記錄

GET /user/spending?page_num=1&page_size=10

Retrieve a paginated list of your billing and token consumption history for completed tasks.

分頁獲取當前賬戶的扣費明細和歷史 Token 消耗記錄(僅顯示已完成併產生費用的任務)。

Response Example響應示例
{
    "code": 0,
    "msg": "Success",
    "data": {
        "items": [
            {
                "id": "cgt-2026123456789",
                "model": "AiVideoMax",
                "call_type": "t2v",
                "tokens_used": 108900,
                "cost": 1.143,
                "created_at": "2026-04-02 21:15:00"
            }
        ],
        "total": 42,
        "page_num": 1,
        "page_size": 10
    }
}

11. Error Codes & Troubleshooting11. 錯誤碼與異常排查

本平臺接口的錯誤返回分爲兩類:同步網關錯誤異步任務錯誤

Our API errors are divided into two types: Synchronous Gateway Errors and Asynchronous Task Errors.

1. 同步網關錯誤 (Synchronous Errors)1. Synchronous Gateway Errors

在請求發起時直接返回(如參數格式不對、模型名稱無效、餘額不足),HTTP 狀態碼通常爲 4xx 或 5xx。失敗時 code 不爲 0。

Returned immediately upon request (e.g., invalid parameters, invalid model name, insufficient balance). HTTP status is usually 4xx or 5xx. On failure, code is not 0.

{
    "code": 400,
    "msg": "Invalid model name. Supported models are: AiVideoMax, AiVideoMin, AiVideoMaxNF, AiVideoMinNF, AiVideoMini, AiVideoMiniNF"
}
2. 異步任務錯誤 (Asynchronous Task Errors)2. Asynchronous Task Errors

任務提交成功後,在輪詢查詢任務狀態 (Query Task) 時,如果 statusfailed,會在返回的 error.code 中提供具體的失敗原因。請務必根據此處的錯誤碼調整您的請求。

When polling task status, if status is failed, the specific reason is provided in error.code. Please adjust your request according to this error code.

{
    "id": "cgt-2026123456789",
    "status": "failed",
    "error": {
        "code": "OutputVideoSensitiveContentDetected",
        "message": "The output video contains sensitive content..."
    }
}
常見異步錯誤碼清單 (Asynchronous Error Codes Reference)Asynchronous Error Codes Reference
錯誤碼 (Error Code)Error Code 含義說明Meaning 排查建議Solution / Suggestion
OutputImageSensitiveContentDetected 輸出畫面敏感(人物/裸露/暴力/版權)Sensitive output image detected 換提示詞、去除具體人物名字、加卡通風格Change prompt, remove specific names, add cartoon style
OutputAudioSensitiveContentDetected 輸出音頻敏感Sensitive output audio detected 關閉音頻 generate_audio: false 或換提示詞Set generate_audio: false or change prompt
InputTextRiskDetected 輸入文本違規Input text violates safety policy 改寫提示詞,避免違禁詞Rewrite prompt, avoid banned words
InputImageRiskDetected 輸入圖片違規Input image violates safety policy 更換參考圖片Change reference image
InvalidParameter 參數錯誤Invalid parameter 檢查 JSON 結構和參數類型Check JSON structure and parameter types
MissingParameter 缺少必填參數Missing required parameter 補齊必填參數Provide all required parameters
InvalidResolution 分辨率不支持Unsupported resolution 使用 4k, 1080p, 720p 或 480p,並確認模型支持對應分辨率Use 4k, 1080p, 720p, or 480p, and make sure the selected model supports that resolution
InvalidDuration 時長不支持Unsupported duration 限制在 4-15 秒之間Keep between 4-15 seconds
InvalidPrompt 提示詞爲空或非法Empty or illegal prompt 檢查 text 字段內容Check the content of the text field
Timeout 生成超時Generation timeout 官方隊列擁堵,稍後重試Upstream queue congested, retry later
TaskFailed 任務執行失敗Task execution failed 官方內部渲染失敗,建議重試Internal rendering failed, suggest retrying
InternalError 服務器內部錯誤Internal server error 官方接口故障,稍後重試Upstream API fault, retry later
ServiceUnavailable 服務繁忙/維護Service busy or under maintenance 稍後重試Retry later
QuotaExhausted / PaymentRequired 額度用完 / 欠費Quota exhausted / Payment required 請聯繫管理員充值Contact administrator for recharge
TooManyRequests / ConcurrentLimitReached 請求頻率超限 / 併發超限Rate limit / Concurrency reached 降低請求或輪詢頻率Reduce request/polling frequency
Unauthorized API Key 無效Invalid API Key 檢查 Authorization 頭是否正確Check if Authorization header is correct