图像
创建 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 或最大为
5 MB 的 Base64 图像数据 URI。Prompt 接受 1 到 1,000 个 UTF-16 代码单元。
选择尺寸
将ratio 设置为架构中列出的任一精确尺寸对。例如,
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>"
}
}