Routerra.ai

API tạo video

Tạo video

Dùng khóa API Routerra và đổi URL gốc thành https://routerra.ai. Giữ nguyên tên mô hình, JSON và đường dẫn truy vấn trạng thái. Thay liên kết mẫu bằng URL công khai.

POST /v1/video/generations

Văn bản thành video

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"
}'

Khung đầu hoặc khung đầu và cuối

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"
}'

Ảnh tham chiếu chủ thể

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"
}'

Tham chiếu ảnh và video

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"
}'

Trạng thái và kết quả tác vụ

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"}]}

Các mô hình khả dụng

Khi tạo tác vụ, kiểm tra trạng thái hoặc tải xuống, hãy gửi khóa API Routerra qua Authorization: Bearer YOUR_API_KEY. Gọi GET /v1/models để xem ID mô hình mà khóa của bạn có thể truy cập.

ID mô hình Độ phân giải đầu ra Thời lượng tối đa
bytedance/seedance-2.5 480p, 720p, 1080p 30 giây
bytedance/seedance-2.0 480p, 720p, 1080p, 4k 15 giây
bytedance/seedance-2.0-fast 480p, 720p 15 giây
bytedance/seedance-2.0-mini 480p, 720p 15 giây

API gốc của Ark

Gửi đối tượng JSON có model và content. Đặt câu lệnh trong mục có kiểu text. Dùng duration để đặt thời lượng theo giây hoặc dùng -1 để mô hình tự chọn. resolution và ratio lần lượt đặt độ phân giải và tỷ lệ khung hình. Kiểm tra trạng thái tác vụ định kỳ. Cổng API từ chối 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"
  }'

Lưu id từ phản hồi tạo tác vụ làm TASK_ID. Tiếp tục kiểm tra khi status là queued hoặc running. Khi trạng thái là succeeded, tải video từ content.video_url. Với failed, expired hoặc cancelled, dừng kiểm tra và xem error nếu có.

curl --fail-with-body 'https://routerra.ai/api/v3/contents/generations/tasks/TASK_ID' \
  -H 'Authorization: Bearer YOUR_API_KEY'

API tương thích OpenAI

Gửi model, prompt và trường tùy chọn seconds. duration là tên thay thế cho seconds. Đặt các tùy chọn của Ark như resolution, ratio và tư liệu tham chiếu trong metadata. Hai ví dụ JSON dùng cùng thiết lập video.

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"}
  }'

Phản hồi tạo tác vụ chứa đối tượng video có id. Lưu giá trị này làm TASK_ID. Tiếp tục kiểm tra khi status là queued hoặc in_progress. Tải kết quả khi trạng thái là completed. Nếu trạng thái là failed, xem error nếu có.

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

API OpenAI Responses

Nếu dùng ứng dụng khách Responses, hãy gửi cùng mô hình với câu lệnh văn bản trong input. Đặt background thành true để nhận phản hồi ngay, rồi dùng id trả về để kiểm tra qua GET /v1/responses/RESPONSE_ID. Khi trạng thái là completed, nội dung output_text chứa phần tử video HTML có URL trong thuộc tính src.

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'

Sử dụng tư liệu tham chiếu

Làm theo hướng dẫn quản lý tư liệu để tạo tư liệu tham chiếu. Dùng ID do GetAsset trả về sau khi Result.Status chuyển thành Active. Thay ASSET_ID trong ví dụ bằng ID đầy đủ. Tư liệu phải thuộc tài khoản Routerra của bạn và có sẵn trên kênh đã chọn.

Thêm mục bên dưới vào content của yêu cầu Ark hoặc metadata.content của yêu cầu tương thích OpenAI. Giữ câu lệnh văn bản ở trường ban đầu. Với mô hình có hỗ trợ, dùng video_url cùng reference_video cho video hoặc audio_url cùng reference_audio cho âm thanh. Trường url cũng chấp nhận URL công khai của tệp đa phương tiện.

{
  "type": "image_url",
  "image_url": {"url": "asset://ASSET_ID"},
  "role": "reference_image"
}

Nếu gửi yêu cầu thất bại, hãy kiểm tra ID mô hình và quyền truy cập của khóa. Nếu HTTP 400 báo rằng tư liệu tham chiếu không khả dụng, hãy kiểm tra quyền sở hữu tư liệu và kênh. Khi nhận HTTP 429, hãy chờ trước khi kiểm tra lại.