together-video
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTogether Video Generation
Together 视频生成
Overview
概述
Generate videos asynchronously — submit a job, poll for completion, download the result.
- Endpoint:
/v2/videos - Async workflow: create job → poll status → download video
- 15+ models from Google, OpenAI, MiniMax, Kuaishou, ByteDance, PixVerse, Vidu
异步生成视频——提交任务、轮询完成状态、下载结果。
- 接口地址:
/v2/videos - 异步工作流:创建任务 → 轮询状态 → 下载视频
- 包含来自Google、OpenAI、MiniMax、快手、字节跳动、PixVerse、Vidu的15+款模型
Quick Start
快速开始
Text-to-Video
文生视频
python
import time
from together import Together
client = Together()
job = client.videos.create(
prompt="A serene sunset over the ocean with gentle waves",
model="minimax/video-01-director",
width=1366,
height=768,
)
print(f"Job ID: {job.id}")python
import time
from together import Together
client = Together()
job = client.videos.create(
prompt="A serene sunset over the ocean with gentle waves",
model="minimax/video-01-director",
width=1366,
height=768,
)
print(f"Job ID: {job.id}")Poll until completion
Poll until completion
while True:
status = client.videos.retrieve(job.id)
if status.status == "completed":
print(f"Video URL: {status.outputs.video_url}")
break
elif status.status == "failed":
print("Failed")
break
time.sleep(5)
```typescript
import Together from "together-ai";
const together = new Together();
const job = await together.videos.create({
prompt: "A serene sunset over the ocean with gentle waves",
model: "minimax/video-01-director",
width: 1366, height: 768,
});
// Poll until completion
while (true) {
const status = await together.videos.retrieve(job.id);
if (status.status === "completed") {
console.log(`Video URL: ${status.outputs.video_url}`);
break;
} else if (status.status === "failed") break;
await new Promise(r => setTimeout(r, 5000));
}shell
undefinedwhile True:
status = client.videos.retrieve(job.id)
if status.status == "completed":
print(f"Video URL: {status.outputs.video_url}")
break
elif status.status == "failed":
print("Failed")
break
time.sleep(5)
```typescript
import Together from "together-ai";
const together = new Together();
const job = await together.videos.create({
prompt: "A serene sunset over the ocean with gentle waves",
model: "minimax/video-01-director",
width: 1366, height: 768,
});
// Poll until completion
while (true) {
const status = await together.videos.retrieve(job.id);
if (status.status === "completed") {
console.log(`Video URL: ${status.outputs.video_url}`);
break;
} else if (status.status === "failed") break;
await new Promise(r => setTimeout(r, 5000));
}shell
undefinedCreate a video generation job
Create a video generation job
curl -X POST "https://api.together.xyz/v2/videos"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/video-01-director", "prompt": "A serene sunset over the ocean with gentle waves", "width": 1366, "height": 768 }'
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/video-01-director", "prompt": "A serene sunset over the ocean with gentle waves", "width": 1366, "height": 768 }'
curl -X POST "https://api.together.xyz/v2/videos"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/video-01-director", "prompt": "A serene sunset over the ocean with gentle waves", "width": 1366, "height": 768 }'
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/video-01-director", "prompt": "A serene sunset over the ocean with gentle waves", "width": 1366, "height": 768 }'
Poll for completion (replace $JOB_ID with the id from the create response)
Poll for completion (replace $JOB_ID with the id from the create response)
curl -X GET "https://api.together.xyz/v2/videos/$JOB_ID"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Authorization: Bearer $TOGETHER_API_KEY"
undefinedcurl -X GET "https://api.together.xyz/v2/videos/$JOB_ID"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Authorization: Bearer $TOGETHER_API_KEY"
undefinedImage-to-Video (Keyframes)
图生视频(关键帧)
python
import base64, requests
image_url = "https://example.com/photo.jpg"
img_data = base64.b64encode(requests.get(image_url).content).decode("utf-8")
job = client.videos.create(
prompt="Smooth camera zoom out",
model="minimax/hailuo-02",
frame_images=[{"input_image": img_data, "frame": 0}],
)typescript
import * as fs from "fs";
import Together from "together-ai";
const together = new Together();
// Load and encode your image
const imageBuffer = fs.readFileSync("keyframe.jpg");
const base64Image = imageBuffer.toString("base64");
const job = await together.videos.create({
prompt: "Smooth camera zoom out",
model: "minimax/hailuo-02",
frame_images: [{ input_image: base64Image, frame: 0 }],
});
// Poll until completion
while (true) {
const status = await together.videos.retrieve(job.id);
if (status.status === "completed") {
console.log(`Video URL: ${status.outputs.video_url}`);
break;
} else if (status.status === "failed") break;
await new Promise(r => setTimeout(r, 5000));
}shell
undefinedpython
import base64, requests
image_url = "https://example.com/photo.jpg"
img_data = base64.b64encode(requests.get(image_url).content).decode("utf-8")
job = client.videos.create(
prompt="Smooth camera zoom out",
model="minimax/hailuo-02",
frame_images=[{"input_image": img_data, "frame": 0}],
)typescript
import * as fs from "fs";
import Together from "together-ai";
const together = new Together();
// Load and encode your image
const imageBuffer = fs.readFileSync("keyframe.jpg");
const base64Image = imageBuffer.toString("base64");
const job = await together.videos.create({
prompt: "Smooth camera zoom out",
model: "minimax/hailuo-02",
frame_images: [{ input_image: base64Image, frame: 0 }],
});
// Poll until completion
while (true) {
const status = await together.videos.retrieve(job.id);
if (status.status === "completed") {
console.log(`Video URL: ${status.outputs.video_url}`);
break;
} else if (status.status === "failed") break;
await new Promise(r => setTimeout(r, 5000));
}shell
undefinedCreate an image-to-video job (replace $BASE64_IMAGE with your base64-encoded image)
Create an image-to-video job (replace $BASE64_IMAGE with your base64-encoded image)
curl -X POST "https://api.together.xyz/v2/videos"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/hailuo-02", "prompt": "Smooth camera zoom out", "frame_images": [{"input_image": "$BASE64_IMAGE", "frame": 0}] }'
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/hailuo-02", "prompt": "Smooth camera zoom out", "frame_images": [{"input_image": "$BASE64_IMAGE", "frame": 0}] }'
curl -X POST "https://api.together.xyz/v2/videos"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/hailuo-02", "prompt": "Smooth camera zoom out", "frame_images": [{"input_image": "$BASE64_IMAGE", "frame": 0}] }'
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "minimax/hailuo-02", "prompt": "Smooth camera zoom out", "frame_images": [{"input_image": "$BASE64_IMAGE", "frame": 0}] }'
Poll for completion (replace $JOB_ID with the id from the create response)
Poll for completion (replace $JOB_ID with the id from the create response)
curl -X GET "https://api.together.xyz/v2/videos/$JOB_ID"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Authorization: Bearer $TOGETHER_API_KEY"
undefinedcurl -X GET "https://api.together.xyz/v2/videos/$JOB_ID"
-H "Authorization: Bearer $TOGETHER_API_KEY"
-H "Authorization: Bearer $TOGETHER_API_KEY"
undefinedReference Images
参考图
python
job = client.videos.create(
prompt="A cat dancing energetically",
model="minimax/hailuo-02",
reference_images=["https://example.com/cat.jpg"],
)python
job = client.videos.create(
prompt="A cat dancing energetically",
model="minimax/hailuo-02",
reference_images=["https://example.com/cat.jpg"],
)Parameters
参数
| Parameter | Type | Description | Default |
|---|---|---|---|
| string | Text description (required for all models except Kling) | - |
| string | Model ID (required) | - |
| int | Video width | 1366 |
| int | Video height | 768 |
| int | Duration (1-10) | 5-6 |
| int | Frames per second | 24-25 |
| int | Diffusion steps | varies |
| float | Prompt adherence (6-10) | varies |
| int | Random seed | random |
| string | What to exclude | - |
| array | Keyframe images (base64) | - |
| array | Style reference URLs | - |
| string | "MP4" or "WEBM" | "MP4" |
| int | Bitrate/quality (lower = higher quality) | 20 |
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| string | 文本描述(除Kling外所有模型必填) | - |
| string | 模型ID(必填) | - |
| int | 视频宽度 | 1366 |
| int | 视频高度 | 768 |
| int | 视频时长(1-10) | 5-6 |
| int | 帧率 | 24-25 |
| int | 扩散步数 | 依模型而定 |
| float | 提示词贴合度(6-10) | 依模型而定 |
| int | 随机种子 | 随机生成 |
| string | 需要排除的内容描述 | - |
| array | 关键帧图片(base64格式) | - |
| array | 风格参考图URL | - |
| string | "MP4" 或 "WEBM" | "MP4" |
| int | 码率/质量(数值越低质量越高) | 20 |
Job Status Flow
任务状态流转
| Status | Description |
|---|---|
| Waiting in queue |
| Generating |
| Done — video URL available |
| Check |
| Job cancelled |
| 状态 | 描述 |
|---|---|
| 队列等待中 |
| 生成中 |
| 已完成——可获取视频URL |
| 生成失败——查看 |
| 任务已取消 |
Guidance Scale Tips
引导系数使用提示
- 6-7: Creative, more interpretation
- 7-9: Balanced (recommended)
- 9-10: Strict prompt adherence
- >12: Avoid — causes artifacts
- 6-7: 创意性强,模型发挥空间更大
- 7-9: 效果均衡(推荐)
- 9-10: 严格遵循提示词描述
- >12: 不建议使用——会产生伪影
Key Models
核心模型
| Model | API String | Duration | Dimensions |
|---|---|---|---|
| Veo 3.0 | | 8s | 1280x720, 1920x1080 |
| Veo 3.0 + Audio | | 8s | 1280x720, 1920x1080 |
| Sora 2 | | 8s | 1280x720 |
| Hailuo 02 | | 10s | 1366x768, 1920x1080 |
| Kling 2.1 Master | | 5s | 1920x1080 |
| Seedance 1.0 Pro | | 5s | Multiple |
| PixVerse v5 | | 5s | Multiple |
| Vidu 2.0 | | 8s | Multiple |
See references/models.md for the complete model table.
| 模型 | API标识 | 时长 | 分辨率 |
|---|---|---|---|
| Veo 3.0 | | 8s | 1280x720, 1920x1080 |
| Veo 3.0 + Audio | | 8s | 1280x720, 1920x1080 |
| Sora 2 | | 8s | 1280x720 |
| Hailuo 02 | | 10s | 1366x768, 1920x1080 |
| Kling 2.1 Master | | 5s | 1920x1080 |
| Seedance 1.0 Pro | | 5s | 多种 |
| PixVerse v5 | | 5s | 多种 |
| Vidu 2.0 | | 8s | 多种 |
查看 references/models.md 获取完整模型列表。
Resources
相关资源
- Full model details: See references/models.md
- Runnable script: See scripts/generate_video.py — async video generation with polling helper (v2 SDK)
- Runnable script (TypeScript): See scripts/generate_video.ts — minimal OpenAPI extraction for create/retrieve video (TypeScript SDK)
x-codeSamples - Official docs: Videos Overview
- API reference: Create Video API