Officieel formaat
Maak een Runway-afbeelding
Gebruik POST /runwayml/v1/text_to_image om een Runway-taak te starten die afbeeldingen genereert op basis van een tekstprompt, met ondersteuning voor 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 appears
const 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"
}Gebruik dit endpoint om een Runway-taak voor het genereren van afbeeldingen te maken.
Gebruiksnotities
- Stuur de vereiste
X-Runway-Versionheader mee, bijvoorbeeld2024-11-06 - Gebruik
model: gen4_image - Deze route vereist ten minste één item in
referenceImages— een aanvraag met alleen tekst retourneertreference_images_empty
Taakverloop
1
Verstuur het generatieverzoek
Stuur
promptText, ratio, model en ten minste één referenceImages-object mee.2
Sla de geretourneerde id op
Bewaar de geretourneerde
id, omdat deze route asynchroon is.3
Poll de taak
Gebruik Een Runway-taak ophalen. Als een onmiddellijke poll
task_not_exist retourneert, wacht dan een paar seconden en probeer het opnieuw.Autorisaties
Bearer token authentication. Use your CometAPI key.
Headers
Runway version header, for example 2024-11-06.
Body
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
Respons
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 appears
const 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"
}