動画生成 API
動画の生成
Routerra の API キーを使用し、ベース URL を https://routerra.ai に変更します。モデル名、JSON、ポーリングのパスはそのまま使用できます。例の URL は公開メディアに置き換えてください。
POST /v1/video/generations
テキストから動画
curl --fail-with-body "https://routerra.ai/v1/video/generations" \
-H "Authorization: Bearer ${ROUTERRA_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"model": "doubao-seedance-2-0",
"prompt": "A paper boat floats across a lake.",
"generate_audio": true,
"duration": 5,
"resolution": "720p",
"ratio": "16:9"
}'
開始フレームまたは開始・終了フレーム
curl --fail-with-body "https://routerra.ai/v1/video/generations" \
-H "Authorization: Bearer ${ROUTERRA_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"model": "doubao-seedance-2-0",
"prompt": "Move from sunrise to sunset.",
"images": [
"https://example.com/first.jpg",
"https://example.com/last.jpg"
],
"duration": 5,
"resolution": "720p",
"ratio": "16:9"
}'
複数の参照画像
curl --fail-with-body "https://routerra.ai/v1/video/generations" \
-H "Authorization: Bearer ${ROUTERRA_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"model": "doubao-seedance-2-0",
"prompt": "Use the boat and lake as visual references.",
"images": [
{
"url": "https://example.com/boat.jpg",
"role": "reference_image"
},
{
"url": "https://example.com/lake.jpg",
"type": "reference_image"
}
],
"duration": 5,
"resolution": "720p",
"ratio": "16:9"
}'
参照画像と参照動画
curl --fail-with-body "https://routerra.ai/v1/video/generations" \
-H "Authorization: Bearer ${ROUTERRA_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"model": "doubao-seedance-2-0",
"prompt": "Animate the boat with the camera motion in the clip.",
"images": [
{
"url": "https://example.com/boat.jpg",
"type": "reference_image"
}
],
"videos": [
"https://example.com/motion.mp4"
],
"duration": 5,
"resolution": "720p",
"ratio": "16:9"
}'
タスクの状態と動画の取得
GET /v1/video/generations/{task_id}
{"id":"task_example","task_id":"task_example","status":"pending","message":"Task submitted successfully"}
curl --fail-with-body "https://routerra.ai/v1/video/generations/${TASK_ID}" \
-H "Authorization: Bearer ${ROUTERRA_API_KEY}"
pending → processing → completed / failed
{"id":"task_example","task_id":"task_example","status":"completed","data":[{"url":"https://example.com/generated.mp4"}]}
利用可能なモデル
作成、状態の照会、ダウンロードのリクエストには、Routerra の API キーを Authorization: Bearer YOUR_API_KEY として送信します。GET /v1/models で、お使いのキーから利用できるモデル ID を確認できます。
| モデル ID | 出力解像度 | 最長時間 |
|---|---|---|
bytedance/seedance-2.5 |
480p, 720p, 1080p | 30秒 |
bytedance/seedance-2.0 |
480p, 720p, 1080p, 4k | 15秒 |
bytedance/seedance-2.0-fast |
480p, 720p | 15秒 |
bytedance/seedance-2.0-mini |
480p, 720p | 15秒 |
Ark ネイティブ API
model と content を含む JSON を送信します。プロンプトは text 型の項目に入れます。duration は秒単位で指定します。-1 を指定するとモデルが長さを決めます。resolution と ratio で解像度とアスペクト比を設定します。進捗はポーリングで確認します。ゲートウェイは callback_url を受け付けません。
curl --fail-with-body 'https://routerra.ai/api/v3/contents/generations/tasks' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedance-2.5",
"content": [{"type": "text", "text": "Slow camera pan across a coastal village at sunrise."}],
"duration": 5,
"resolution": "720p",
"ratio": "16:9"
}'
作成レスポンスの id を TASK_ID として保存します。status が queued または running の間はポーリングを続けます。succeeded になったら content.video_url から動画をダウンロードします。failed、expired、cancelled の場合はポーリングを終了し、error があれば確認してください。
curl --fail-with-body 'https://routerra.ai/api/v3/contents/generations/tasks/TASK_ID' \
-H 'Authorization: Bearer YOUR_API_KEY'
OpenAI 互換 API
model、prompt、必要に応じて seconds を指定します。duration は seconds の別名です。resolution、ratio、参照素材など Ark 固有の設定は metadata に入れます。2 つの JSON 例では同じ動画設定を使っています。
curl --fail-with-body 'https://routerra.ai/v1/videos' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedance-2.5",
"prompt": "Slow camera pan across a coastal village at sunrise.",
"seconds": "5",
"metadata": {"resolution": "720p", "ratio": "16:9"}
}'
作成レスポンスの動画オブジェクトに含まれる id を TASK_ID として保存します。status が queued または in_progress の間はポーリングを続け、completed になったら動画をダウンロードします。failed の場合は error があれば確認してください。
curl --fail-with-body 'https://routerra.ai/v1/videos/TASK_ID' \
-H 'Authorization: Bearer YOUR_API_KEY'
curl --fail-with-body 'https://routerra.ai/v1/videos/TASK_ID/content' \
-H 'Authorization: Bearer YOUR_API_KEY' \
--output video.mp4
OpenAI Responses API
Responses クライアントでは、同じモデルを指定し、テキストのプロンプトを input に入れます。background を true にするとすぐにレスポンスが返ります。返された id を使い、GET /v1/responses/RESPONSE_ID をポーリングします。状態が completed になると、output_text の内容に HTML 動画要素が含まれ、その src 属性に動画 URL が入ります。
curl --fail-with-body 'https://routerra.ai/v1/responses' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data '{
"model": "bytedance/seedance-2.5",
"input": "Slow camera pan across a coastal village at sunrise.",
"background": true,
"seconds": 5,
"metadata": {"resolution": "720p", "ratio": "16:9"}
}'
curl --fail-with-body 'https://routerra.ai/v1/responses/RESPONSE_ID' \
-H 'Authorization: Bearer YOUR_API_KEY'
参照素材を使う
素材管理ガイドに従って参照素材を作成します。GetAsset を呼び出し、Result.Status が Active になったら、返された素材 ID を使います。例の ASSET_ID を素材 ID 全体に置き換えてください。素材がご自身の Routerra アカウントに所属し、選択されたチャネルで利用できる必要があります。
以下の項目を Ark リクエストの content、または OpenAI 互換リクエストの metadata.content に加えます。テキストのプロンプトは元のフィールドに残します。対応モデルでは動画の参照に video_url と reference_video を、音声の参照に audio_url と reference_audio を使います。url には公開メディア URL も指定できます。
{
"type": "image_url",
"image_url": {"url": "asset://ASSET_ID"},
"role": "reference_image"
}
送信に失敗した場合は、モデル ID とキーのアクセス権を確認してください。参照素材が利用できないことを示す HTTP 400 が返った場合は、素材の所有者とチャネルを確認してください。HTTP 429 が返った場合は、時間をおいてから再度照会してください。