공식 형식
Runway 이미지 생성하기
POST /runwayml/v1/text_to_image를 사용해 텍스트 프롬프트에서 이미지를 생성하는 Runway 작업을 시작하며, X-Runway-Version을 지원합니다.
POST
/
runwayml
/
v1
/
text_to_image
cURL
curl https://api.cometapi.com/runwayml/v1/text_to_image \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/text_to_image",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
},
)
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/text_to_image", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
}),
});
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/text_to_image",
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([
'promptText' => 'A paper boat floating on calm water at sunrise.',
'ratio' => '1280:720',
'seed' => 1,
'model' => 'gen4_image',
'referenceImages' => [
[
'uri' => 'https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg',
'tag' => 'style_ref'
]
],
'contentModeration' => [
'publicFigureThreshold' => 'auto'
]
]),
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/text_to_image"
payload := strings.NewReader("{\n \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\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/text_to_image")
.header("X-Runway-Version", "<x-runway-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/text_to_image")
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 \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "31f9c5b2-ea5c-421c-8044-75a6bb53211d"
}이 엔드포인트를 사용해 Runway 이미지 생성 작업을 만들 수 있습니다.
사용 참고 사항
- 필수
X-Runway-Version헤더를 전송하세요. 예:2024-11-06 model: gen4_image를 사용하세요- 이 경로는 최소 하나의
referenceImages항목이 필요합니다 — 텍스트만 포함한 요청은reference_images_empty를 반환합니다
작업 흐름
1
생성 요청 제출
promptText, ratio, model, 그리고 최소 하나의 referenceImages 객체를 전송하세요.2
반환된 id 저장
이 경로는 비동기식이므로 반환된
id를 보관하세요.3
작업 폴링
Runway 작업 가져오기를 사용하세요. 즉시 폴링했을 때
task_not_exist가 반환되면 몇 초 기다린 후 다시 시도하세요.인증
Bearer token authentication. Use your CometAPI key.
헤더
Runway version header, for example 2024-11-06.
본문
application/json
A non-empty string up to 1000 characters.
Aspect ratio of the output image, e.g. 1280:720.
Random seed for reproducible results.
The model variant to use.
An array of up to three images to be used as references. At least one item is required. referenceImages is required.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
응답
200 - application/json
Task accepted.
⌘I
cURL
curl https://api.cometapi.com/runwayml/v1/text_to_image \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/text_to_image",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
},
)
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/text_to_image", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"promptText": "A paper boat floating on calm water at sunrise.",
"ratio": "1280:720",
"model": "gen4_image",
"referenceImages": [
{
"uri": "https://your-image-host/reference.jpg",
"tag": "ref"
}
]
}),
});
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/text_to_image",
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([
'promptText' => 'A paper boat floating on calm water at sunrise.',
'ratio' => '1280:720',
'seed' => 1,
'model' => 'gen4_image',
'referenceImages' => [
[
'uri' => 'https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg',
'tag' => 'style_ref'
]
],
'contentModeration' => [
'publicFigureThreshold' => 'auto'
]
]),
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/text_to_image"
payload := strings.NewReader("{\n \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\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/text_to_image")
.header("X-Runway-Version", "<x-runway-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/text_to_image")
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 \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n \"ratio\": \"1280:720\",\n \"seed\": 1,\n \"model\": \"gen4_image\",\n \"referenceImages\": [\n {\n \"uri\": \"https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg\",\n \"tag\": \"style_ref\"\n }\n ],\n \"contentModeration\": {\n \"publicFigureThreshold\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "31f9c5b2-ea5c-421c-8044-75a6bb53211d"
}