视频生成
概述
Atlas Cloud 通过统一的 API 提供对行业领先的 AI 视频生成模型的访问。从文本提示、图像或现有视频片段生成高质量视频,只需一次 API 调用即可完成。
支持的模型类型
| 类型 | 描述 | 用例 |
|---|---|---|
| 文生视频 | 从文本描述生成视频 | 创意内容、营销素材、原型制作 |
| 图生视频 | 将静态图像动画化为动态视频 | 产品演示、角色动画、场景创建 |
| 视频转视频 | 变换和增强现有视频 | 风格迁移、视频增强、特效 |
| 音频转视频 | 生成与音频同步的视频 | 音乐视频、播客可视化、演示文稿 |
精选模型
| 模型 | 供应商 | 亮点 |
|---|---|---|
| Kling | KwaiVGI | 高质量视频生成,精确的运动控制,提供多个版本 |
| Vidu | Vidu | 下一代视频 AI,电影级画质 |
| Seedance | ByteDance | 先进的舞蹈和运动视频生成 |
| Wan | 阿里巴巴 | 强大的视频生成,提示词遵循度高 |
| Hailuo | MiniMax | 创意视频生成,风格多样 |
| Veo | Google 最先进的视频生成模型 | |
| Luma | Luma AI | 专业级 AI 视频生成 |
| PixVerse | PixVerse | 多功能视频生成和编辑 |
有关所有视频模型及其规格的完整列表,请访问模型库。
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
# 第 1 步:上传源图片
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")
# 第 2 步:从图片生成视频
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 参考。