建立一個 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"
}