api-reference
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRunway Public API Reference
Runway 公共API参考
PREREQUISITE: Runfirst to ensure the project has server-side capability.+check-compatibility
Base URL:
https://api.dev.runwayml.comAll requests require these headers:
Authorization: Bearer <RUNWAYML_API_SECRET>
X-Runway-Version: 2024-11-06前提条件: 请先运行以确保项目具备服务端运行能力。+check-compatibility
基础URL:
https://api.dev.runwayml.com所有请求都需要携带以下请求头:
Authorization: Bearer <RUNWAYML_API_SECRET>
X-Runway-Version: 2024-11-06Models & Endpoints
模型与端点
Video Generation
视频生成
| Model | Endpoint | Input | Cost (credits/sec) |
|---|---|---|---|
| | Text and/or Image | 12 |
| | Image required | 5 |
| | Video + Text/Image | 15 |
| | Image/Video | 5 |
| | Text/Image | 40 |
| | Text/Image | 20-40 |
| | Text/Image | 10-15 |
Video duration: 2-10 seconds. Aspect ratios: , , , etc.
1280:720720:12801104:832| 模型 | 端点 | 输入 | 成本(积分/秒) |
|---|---|---|---|
| | 文本和/或图像 | 12 |
| | 必须传入图像 | 5 |
| | 视频 + 文本/图像 | 15 |
| | 图像/视频 | 5 |
| | 文本/图像 | 40 |
| | 文本/图像 | 20-40 |
| | 文本/图像 | 10-15 |
视频时长:2-10秒。支持的宽高比:、、 等。
1280:720720:12801104:832Image Generation
图像生成
| Model | Endpoint | Cost (credits) |
|---|---|---|
| | 5 (720p), 8 (1080p) |
| | 2 |
| | 5 |
| 模型 | 端点 | 成本(积分) |
|---|---|---|
| | 5(720p)、8(1080p) |
| | 2 |
| | 5 |
Audio Generation
音频生成
| Model | Endpoint | Use Case | Cost |
|---|---|---|---|
| | Text to speech | 1 credit/50 chars |
| | Sound effects | 1-2 credits |
| | Isolate voice from audio | 1 credit/6 sec |
| | Dub audio to other languages | 1 credit/2 sec |
| | Voice conversion | 1 credit/3 sec |
| 模型 | 端点 | 使用场景 | 成本 |
|---|---|---|---|
| | 文本转语音 | 1积分/50字符 |
| | 音效生成 | 1-2积分 |
| | 音频人声分离 | 1积分/6秒 |
| | 多语言音频配音 | 1积分/2秒 |
| | 声音转换 | 1积分/3秒 |
Characters (Real-Time Avatars)
角色(实时数字人)
| Model | Description | Session Max Duration |
|---|---|---|
| Real-time conversational avatars powered by GWM-1 | 5 minutes |
Endpoints:
| Method | Endpoint | Description |
|---|---|---|
| | Create a new Avatar |
| | Retrieve an Avatar |
| | Update an Avatar (name, voice, personality, documentIds) |
| | Delete an Avatar |
| | Create a new real-time session |
| | Retrieve session status (poll until |
| | Consume session credentials for WebRTC (one-time use) |
Avatar creation parameters:
| Parameter | Type | Description |
|---|---|---|
| string | Display name for the avatar |
| string | URL or |
| object | |
| string | System prompt / personality instructions |
| string[] | Optional. IDs of knowledge base documents to attach |
Voice presets: (soft), (firm), (authoritative). Preview all at dev.runwayml.com.
claravictoriavincentSession statuses: → → → (or / )
NOT_READYREADYRUNNINGCOMPLETEDFAILEDCANCELLED| 模型 | 描述 | 会话最大时长 |
|---|---|---|
| 由GWM-1驱动的实时对话数字人 | 5分钟 |
端点列表:
| 请求方法 | 端点 | 描述 |
|---|---|---|
| | 创建新的数字人 |
| | 获取指定数字人信息 |
| | 更新数字人信息(名称、声音、人设、关联文档ID) |
| | 删除指定数字人 |
| | 创建新的实时会话 |
| | 查询会话状态(轮询直到状态变为 |
| | 获取WebRTC会话凭证(单次有效) |
数字人创建参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| string | 数字人展示名称 |
| string | 角色形象图片的URL或 |
| object | 格式为 |
| string | 系统提示词/人设指令 |
| string[] | 可选,要关联的知识库文档ID列表 |
会话状态流转: → → → (或 / )
NOT_READYREADYRUNNINGCOMPLETEDFAILEDCANCELLEDDocuments (Knowledge Base)
文档(知识库)
| Method | Endpoint | Description |
|---|---|---|
| | Create a document (plain text or Markdown) |
| | Retrieve a document |
| | Delete a document |
Each Avatar supports up to 50,000 tokens of knowledge. Link documents to an Avatar via .
client.avatars.update(id, { documentIds: [...] })| 请求方法 | 端点 | 描述 |
|---|---|---|
| | 创建文档(支持纯文本或Markdown) |
| | 获取指定文档内容 |
| | 删除指定文档 |
每个数字人最多支持 5万token 的知识库容量。可通过 为数字人关联知识库文档。
client.avatars.update(id, { documentIds: [...] })Management Endpoints
管理端点
| Method | Endpoint | Description |
|---|---|---|
| | Get task status and output |
| | Cancel/delete a task |
| | Create ephemeral upload |
| | Organization info & credit balance |
| | Credit usage history (up to 90 days) |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| | 获取任务状态和输出结果 |
| | 取消/删除任务 |
| | 创建临时上传凭证 |
| | 获取组织信息和积分余额 |
| | 查询积分使用历史(最多支持90天) |
Task Lifecycle
任务生命周期
All generation endpoints return a task object. The flow is:
- Submit — → returns
POST /v1/<endpoint>{ "id": "task_xxx" } - Poll — → returns task with
GET /v1/tasks/{id}status - Retrieve output — When , the
status === "SUCCEEDED"array contains signed URLsoutput
所有生成类接口都会返回一个任务对象,调用流程如下:
- 提交任务 — 调用 → 返回
POST /v1/<endpoint>{ "id": "task_xxx" } - 轮询状态 — 调用 → 返回带
GET /v1/tasks/{id}字段的任务信息status - 获取输出 — 当 时,
status === "SUCCEEDED"数组包含生成资源的签名URLoutput
Task Statuses
任务状态
| Status | Meaning |
|---|---|
| Queued, waiting to start |
| Currently generating |
| Complete — output URLs available |
| Generation failed — check |
| Concurrency limit hit — auto-queued |
| 状态 | 含义 |
|---|---|
| 队列中,等待执行 |
| 生成中 |
| 生成完成,可获取输出URL |
| 生成失败,请查看 |
| 并发达到上限,已自动进入队列等待 |
SDK Polling (Recommended)
SDK轮询(推荐)
The SDKs provide a method that handles polling automatically:
waitForTaskOutput()javascript
// Node.js — polls until complete (default 10 min timeout)
const task = await client.imageToVideo.create({
model: 'gen4.5',
promptImage: 'https://example.com/image.jpg',
promptText: 'A sunset timelapse',
ratio: '1280:720',
duration: 5
}).waitForTaskOutput();
console.log(task.output); // Array of signed URLspython
undefined官方SDK提供了 方法,可自动处理轮询逻辑:
waitForTaskOutput()javascript
// Node.js — 自动轮询直到任务完成(默认超时时间10分钟)
const task = await client.imageToVideo.create({
model: 'gen4.5',
promptImage: 'https://example.com/image.jpg',
promptText: 'A sunset timelapse',
ratio: '1280:720',
duration: 5
}).waitForTaskOutput();
console.log(task.output); // 签名URL数组python
undefinedPython
Python
task = client.image_to_video.create(
model='gen4.5',
prompt_image='https://example.com/image.jpg',
prompt_text='A sunset timelapse',
ratio='1280:720',
duration=5
).wait_for_task_output()
print(task.output)
undefinedtask = client.image_to_video.create(
model='gen4.5',
prompt_image='https://example.com/image.jpg',
prompt_text='A sunset timelapse',
ratio='1280:720',
duration=5
).wait_for_task_output()
print(task.output)
undefinedManual Polling (REST)
手动轮询(REST)
javascript
async function pollTask(taskId) {
while (true) {
const response = await fetch(`https://api.dev.runwayml.com/v1/tasks/${taskId}`, {
headers: {
'Authorization': `Bearer ${process.env.RUNWAYML_API_SECRET}`,
'X-Runway-Version': '2024-11-06'
}
});
const task = await response.json();
if (task.status === 'SUCCEEDED') return task;
if (task.status === 'FAILED') throw new Error(task.failure);
await new Promise(r => setTimeout(r, 5000)); // poll every 5 seconds
}
}javascript
async function pollTask(taskId) {
while (true) {
const response = await fetch(`https://api.dev.runwayml.com/v1/tasks/${taskId}`, {
headers: {
'Authorization': `Bearer ${process.env.RUNWAYML_API_SECRET}`,
'X-Runway-Version': '2024-11-06'
}
});
const task = await response.json();
if (task.status === 'SUCCEEDED') return task;
if (task.status === 'FAILED') throw new Error(task.failure);
await new Promise(r => setTimeout(r, 5000)); // 每5秒轮询一次
}
}Output Handling
输出处理
- Successful tasks return an array with signed URLs to generated content
output - Output URLs expire within 24-48 hours
- Download and store outputs in your own storage — do not serve signed URLs to end users
- Video outputs are MP4, image outputs are PNG/JPEG
- 成功执行的任务会返回数组,其中包含生成内容的签名URL
output - 输出URL的有效期为24-48小时
- 请将输出内容下载并存储到你自己的存储服务中,不要直接将签名URL提供给终端用户
- 视频输出为MP4格式,图像输出为PNG/JPEG格式
Input Requirements
输入要求
Size Limits
大小限制
| Type | Via URL | Via Data URI | Via Upload |
|---|---|---|---|
| Image | 16 MB | 5 MB | 200 MB |
| Video | 32 MB | 16 MB | 200 MB |
| Audio | 32 MB | 16 MB | 200 MB |
| 类型 | URL传入 | Data URI传入 | 上传传入 |
|---|---|---|---|
| 图像 | 16 MB | 5 MB | 200 MB |
| 视频 | 32 MB | 16 MB | 200 MB |
| 音频 | 32 MB | 16 MB | 200 MB |
Supported Formats
支持的格式
- Images: JPEG, PNG, WebP (no GIF)
- Video codecs: H.264, H.265/HEVC, AV1, VP8/VP9, Apple ProRes, Theora
- Audio: MP3, AAC, FLAC, PCM, ALAC
- 图像: JPEG、PNG、WebP(不支持GIF)
- 视频编码: H.264、H.265/HEVC、AV1、VP8/VP9、Apple ProRes、Theora
- 音频: MP3、AAC、FLAC、PCM、ALAC
URL Requirements
URL要求
If providing assets via URL:
- HTTPS only (no HTTP)
- Domain names only (no IP addresses)
- No redirects
- Must support HTTP HEAD requests
- Must return valid and
Content-TypeheadersContent-Length - Max URL length: 2,048 characters
如果通过URL传入资源:
- 仅支持HTTPS(不支持HTTP)
- 仅支持域名(不支持IP地址)
- 不能有重定向
- 必须支持HTTP HEAD请求
- 必须返回有效的和
Content-Type响应头Content-Length - URL最大长度:2048字符
Rate Limits & Tiers
速率限制与等级
| Tier | Concurrency | Daily Gens | Monthly Cap | Unlock |
|---|---|---|---|---|
| 1 (default) | 1-2 | 50-200 | $100 | — |
| 2 | 3 | 500-1,000 | $500 | 1 day + $50 |
| 3 | 5 | 1,000-2,000 | $2,000 | 7 days + $100 |
| 4 | 10 | 5,000-10,000 | $20,000 | 14 days + $1,000 |
| 5 | 20 | 25,000-30,000 | $100,000 | 7 days + $5,000 |
- No requests-per-minute limit — only daily generation quotas
- Exceeding concurrency → status (auto-queued, not rejected)
THROTTLED - Exceeding daily limit →
429 Too Many Requests - Daily limits use a rolling 24-hour window
| 等级 | 并发数 | 日生成量上限 | 月消费上限 | 解锁条件 |
|---|---|---|---|---|
| 1(默认) | 1-2 | 50-200 | $100 | — |
| 2 | 3 | 500-1000 | $500 | 使用满1天 + 消费满$50 |
| 3 | 5 | 1000-2000 | $2000 | 使用满7天 + 消费满$100 |
| 4 | 10 | 5000-10000 | $20000 | 使用满14天 + 消费满$1000 |
| 5 | 20 | 25000-30000 | $100000 | 使用满7天 + 消费满$5000 |
- 没有每分钟请求次数限制,仅限制日生成配额
- 超过并发限制 → 返回状态(自动进入队列,不会直接拒绝请求)
THROTTLED - 超过日配额限制 → 返回
429 Too Many Requests - 日限制采用滚动24小时窗口计算
Error Handling
错误处理
HTTP Errors
HTTP错误
| Code | Meaning | Action |
|---|---|---|
| 400 | Input validation failure | Fix input, do not retry |
| 401 | Invalid API key | Check key, do not retry |
| 429 | Rate limited | Retry with exponential backoff + jitter |
| 502/503/504 | Server overload | Retry with exponential backoff + jitter |
| 状态码 | 含义 | 处理建议 |
|---|---|---|
| 400 | 输入参数校验失败 | 修正输入参数,不要重试 |
| 401 | API密钥无效 | 检查密钥是否正确,不要重试 |
| 429 | 触发速率限制 | 采用指数退避+随机抖动策略重试 |
| 502/503/504 | 服务端过载 | 采用指数退避+随机抖动策略重试 |
Task Failure Codes
任务失败错误码
| Code | Meaning | Retry? |
|---|---|---|
| Input content moderation | No — not refundable |
| Output content moderation | Yes — try different prompt |
| Quality issue | Yes |
| Bad input format | Fix input |
| Server error | Yes |
The SDKs handle retries for transient errors automatically.
| 错误码 | 含义 | 可重试? |
|---|---|---|
| 输入内容未通过内容审核 | 不可重试,不予退款 |
| 输出内容未通过内容审核 | 可重试,尝试更换提示词 |
| 生成内容质量不合格 | 可重试 |
| 输入资源格式错误 | 修正输入资源后重试 |
| 服务端错误 | 可重试 |
SDK会自动处理瞬时错误的重试逻辑。
Data URI Support
Data URI支持
Base64-encoded images can be passed instead of URLs:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...Useful for small images or when you don't want to host the file. Subject to the data URI size limits above.
可以传入Base64编码的图像替代URL:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...该方式适合小图像,或不想托管文件的场景,需遵守上文提到的Data URI大小限制。