创建一个 Runway 图生视频任务
使用 CometAPI Runway POST /runwayml/v1/video_to_video 启动图生视频生成任务,设置 X-Runway-Version,并转换源片段。
curl https://api.cometapi.com/runwayml/v1/video_to_video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/video_to_video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
},
)
task = response.json()
print(task["id"]) # poll GET /runwayml/v1/tasks/{id} until the output array appearsconst response = await fetch("https://api.cometapi.com/runwayml/v1/video_to_video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
}),
});
const task = await response.json();
console.log(task.id); // poll GET /runwayml/v1/tasks/{id} until the output array appears<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/runwayml/v1/video_to_video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'videoUri' => 'https://media.w3.org/2010/05/sintel/trailer.mp4',
'promptText' => 'Make the motion feel cinematic.',
'model' => 'gen4_aleph',
'references' => [
[
'type' => 'image',
'uri' => 'https://res.cloudinary.com/demo/image/upload/dog.jpg'
]
],
'ratio' => '1280:720'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Runway-Version: <x-runway-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/runwayml/v1/video_to_video"
payload := strings.NewReader("{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Runway-Version", "<x-runway-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/runwayml/v1/video_to_video")
.header("X-Runway-Version", "<x-runway-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/video_to_video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Runway-Version"] = '<x-runway-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}"
response = http.request(request)
puts response.read_body{
"id": "12a01a5e-ab55-4aa7-b002-7b873546cf76"
}调用前准备
- 准备一个符合提供方输入要求的源视频
- 包含所需的
X-Runway-Version请求头,以启用你想要的功能集 - 从一条描述变更的简短 Prompt 开始,而不是完整分镜脚本
输出比例
| 设置 | 支持的值 | 默认起始值 | 边界行为 |
|---|---|---|---|
ratio | 1280:720、720:1280,或所选 Runway model/version 接受的其他比例 | 1280:720 | 在可能的情况下,与源片段方向保持一致。 |
ratio 值。对 1280x720 输出使用 1280:720,对 720x1280 输出使用 720:1280;并非每个 Runway 图生视频路由都接受 1280x720。
任务流程
提交源片段和 Prompt
轮询任务详情
存储转换结果
授权
Bearer token authentication. Use your CometAPI key.
请求头
Runway API version header, for example 2024-11-06.
请求体
HTTPS URL of the source video, or a base64 data URI containing the video.
Text prompt describing the desired output. Maximum 1000 characters.
Random seed for reproducible results. Range: 0–4294967295.
Model variant to use.
Optional reference images to guide generation. Each item must include type (e.g. image) and uri (HTTPS URL).
Show child attributes
Show child attributes
Requested output frame shape. Use colon-separated values such as 1280:720 or 720:1280; read them as 1280x720 and 720x1280 targets. Do not assume every Runway video-to-video route accepts 1280x720 with an x separator.
Show child attributes
Show child attributes
响应
success
The ID of the task that was created. Use this to retrieve the task later.
curl https://api.cometapi.com/runwayml/v1/video_to_video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/video_to_video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
},
)
task = response.json()
print(task["id"]) # poll GET /runwayml/v1/tasks/{id} until the output array appearsconst response = await fetch("https://api.cometapi.com/runwayml/v1/video_to_video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"videoUri": "https://your-video-host/source.mp4",
"promptText": "Make the motion feel cinematic.",
"model": "gen4_aleph",
"references": [
{
"type": "image",
"uri": "https://your-image-host/style.jpg"
}
]
}),
});
const task = await response.json();
console.log(task.id); // poll GET /runwayml/v1/tasks/{id} until the output array appears<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/runwayml/v1/video_to_video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'videoUri' => 'https://media.w3.org/2010/05/sintel/trailer.mp4',
'promptText' => 'Make the motion feel cinematic.',
'model' => 'gen4_aleph',
'references' => [
[
'type' => 'image',
'uri' => 'https://res.cloudinary.com/demo/image/upload/dog.jpg'
]
],
'ratio' => '1280:720'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Runway-Version: <x-runway-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/runwayml/v1/video_to_video"
payload := strings.NewReader("{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Runway-Version", "<x-runway-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/runwayml/v1/video_to_video")
.header("X-Runway-Version", "<x-runway-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/video_to_video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Runway-Version"] = '<x-runway-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"videoUri\": \"https://media.w3.org/2010/05/sintel/trailer.mp4\",\n \"promptText\": \"Make the motion feel cinematic.\",\n \"model\": \"gen4_aleph\",\n \"references\": [\n {\n \"type\": \"image\",\n \"uri\": \"https://res.cloudinary.com/demo/image/upload/dog.jpg\"\n }\n ],\n \"ratio\": \"1280:720\"\n}"
response = http.request(request)
puts response.read_body{
"id": "12a01a5e-ab55-4aa7-b002-7b873546cf76"
}