影片生成

概覽

Atlas Cloud 透過統一 API 提供業界領先的 AI 影片生成模型存取。只需一次 API 呼叫,即可從文字提示、圖片或現有影片片段生成高品質影片。

支援的模型類型

類型說明使用場景
文字轉影片從文字描述生成影片創意內容、行銷、原型製作
圖片轉影片將靜態圖片製作成動態影片產品展示、角色動畫、場景建立
影片轉影片轉換和增強現有影片風格轉換、影片增強、特效
音訊轉影片生成與音訊同步的影片音樂影片、播客視覺化、簡報

精選模型

模型供應商特點
KlingKwaiVGI高品質影片生成,精確運動控制,提供多個版本
ViduVidu新一代影片 AI,電影級品質
SeedanceByteDance先進的舞蹈和運動影片生成
WanAlibaba強大的影片生成,出色的提示詞遵循能力
HailuoMiniMax創意影片生成,多樣化風格
VeoGoogleGoogle 最先進的影片生成模型
LumaLuma AI專業級 AI 影片生成
PixVersePixVerse多功能影片生成和編輯

如需所有影片模型的完整列表和規格,請造訪模型庫

API 使用

文字轉影片

import requests

response = requests.post(
    "https://api.atlascloud.ai/api/v1/model/generateVideo",
    headers={
        "Authorization": "Bearer your-api-key",
        "Content-Type": "application/json"
    },
    json={
        "model": "kling-v2.0",
        "prompt": "A rocket launching into space with dramatic lighting and smoke effects"
    }
)

prediction_id = response.json()["data"]["id"]
print(f"Task submitted. Prediction ID: {prediction_id}")

圖片轉影片

對於圖片轉影片工作流程,先使用上傳媒體端點上傳來源圖片,然後將回傳的 URL 傳遞給影片生成請求:

import requests

# 第一步:上傳來源圖片
upload_response = requests.post(
    "https://api.atlascloud.ai/api/v1/model/uploadMedia",
    headers={"Authorization": "Bearer your-api-key"},
    files={"file": open("source_image.jpg", "rb")}
)
image_url = upload_response.json().get("url")

# 第二步:從圖片生成影片
response = requests.post(
    "https://api.atlascloud.ai/api/v1/model/generateVideo",
    headers={
        "Authorization": "Bearer your-api-key",
        "Content-Type": "application/json"
    },
    json={
        "model": "kling-v2.0",
        "prompt": "The person in the image starts walking forward",
        "image_url": image_url
    }
)

prediction_id = response.json()["data"]["id"]

查看生成狀態

影片生成為非同步處理。使用 prediction ID 輪詢取得結果:

import requests
import time

def get_result(prediction_id, api_key):
    while True:
        response = requests.get(
            f"https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}",
            headers={"Authorization": f"Bearer {api_key}"}
        )
        result = response.json()

        if result["data"]["status"] == "completed":
            return result["data"]["outputs"][0]
        elif result["data"]["status"] == "failed":
            raise Exception(f"Generation failed: {result['data'].get('error')}")

        time.sleep(5)  # 每 5 秒輪詢一次

output = get_result(prediction_id, "your-api-key")
print(f"Video URL: {output}")

Node.js 範例

const response = await fetch(
  "https://api.atlascloud.ai/api/v1/model/generateVideo",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer your-api-key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "kling-v2.0",
      prompt: "A beautiful timelapse of clouds moving over a mountain range",
    }),
  }
);

const data = await response.json();
const predictionId = data.data.id;
console.log(`Task submitted. Prediction ID: ${predictionId}`);

模型選擇建議

  • 品質與速度:較新的模型版本(如 Kling v3.0)通常品質更好,但生成時間可能更長
  • 運動控制:部分模型提供更好的鏡頭運動和主體運動控制
  • 風格:不同模型擅長不同風格——寫實、動漫、電影級等
  • 解析度和時長:在模型詳情頁面查看各模型支援的解析度和最大影片時長

模型庫瀏覽和比較模型。每個模型頁面包含互動式 Playground 供測試使用,以及詳細的參數文件。

完整的 API 規格請參閱 API 參考