圖像
建立 Runway 圖片
使用文字和參考圖片,透過 Gen-4 Image 或 Gen-4 Image Turbo 生成圖片。
POST
/
runwayml
/
v1
/
text_to_image
curl "https://api.cometapi.com/runwayml/v1/text_to_image" \
--request POST \
--header "Authorization: Bearer $COMETAPI_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gen4_image",
"promptText": "A watercolor portrait of @cat_ref.",
"ratio": "1024:1024",
"referenceImages": [
{
"uri": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
"tag": "cat_ref"
}
]
}'
{
"id": "00000000-0000-4000-8000-000000000001"
}{
"code": "<string>",
"message": "<string>",
"data": "<unknown>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}使用此端點可根據 Prompt 生成圖片,並可選擇提供參考
圖片以用於
對於
gen4_image。請透過 Bearer 驗證傳送您的 CometAPI API 金鑰
以及 JSON 請求主體。
選擇模型與參考圖片
每個請求都必須包含model、promptText 和 ratio。
| 模型 | referenceImages |
|---|---|
gen4_image | 選用。省略此欄位或使用 [] 以僅根據文字生成,或提供最多三張圖片。 |
gen4_image_turbo | 提供一至三張圖片。 |
gen4_image_turbo,必須提供 referenceImages,且其中必須包含一至
三張圖片。每個參考物件都包含圖片 uri 與選用的
tag。使用由 3 至 16 個小寫字母、
數字或底線組成,且以字母開頭的標籤。在 promptText 中將其參照為
@tag,例如 @cat_ref。
圖片 URI 可接受可存取的 HTTPS URL 或 Base64 圖片資料 URI,大小上限為
5 MB。Prompt 可接受 1 至 1,000 個 UTF-16 編碼單元。
選擇尺寸
將ratio 設為 schema 中其中一組完全相符的尺寸組合。例如,
1024:1024 會要求正方形圖片,1280:720 會要求橫向圖片,而
720:1280 會要求直向圖片。使用 ratio 選擇尺寸;請勿傳送
resolution 或 size 搭配這些模型。
若要指定明確的取樣種子,請使用 1 至 4294967295。省略或設為 0
會選擇隨機種子。若您包含 contentModeration,請將其
publicFigureThreshold 設為 auto 或 low;否則請省略該物件。
取得結果
儲存傳回的id 並使用 取得 Runway 工作.
當 status 為 SUCCEEDED 時,請從 output 讀取生成的圖片 URL。主體
application/json
- gen4_image
- gen4_image_turbo
Request parameters for gen4_image.
回應
Task submitted. Save its id to retrieve task status.
最後修改於 2026年9月22日
⌘I
curl "https://api.cometapi.com/runwayml/v1/text_to_image" \
--request POST \
--header "Authorization: Bearer $COMETAPI_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gen4_image",
"promptText": "A watercolor portrait of @cat_ref.",
"ratio": "1024:1024",
"referenceImages": [
{
"uri": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
"tag": "cat_ref"
}
]
}'
{
"id": "00000000-0000-4000-8000-000000000001"
}{
"code": "<string>",
"message": "<string>",
"data": "<unknown>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}