{
  "openapi": "3.1.0",
  "info": {
    "title": "Generate an Image from Text API",
    "version": "1.0.0",
    "description": "Create a Runway image-generation task through the official-format CometAPI route. At least one reference image is required."
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/runwayml/v1/text_to_image": {
      "post": {
        "summary": "Create a Runway image-generation task",
        "operationId": "generate_an_image_from_text",
        "description": "Submit the prompt, ratio, model, and at least one `referenceImages` object.",
        "parameters": [
          {
            "name": "X-Runway-Version",
            "in": "header",
            "required": true,
            "description": "Runway version header, for example `2024-11-06`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "promptText",
                  "ratio",
                  "seed",
                  "model",
                  "referenceImages",
                  "contentModeration"
                ],
                "properties": {
                  "promptText": {
                    "type": "string",
                    "description": "A non-empty string up to 1000 characters.",
                    "default": "A paper boat floating on calm water at sunrise."
                  },
                  "ratio": {
                    "type": "string",
                    "description": "Aspect ratio of the output image, e.g. `1280:720`.",
                    "default": "1280:720"
                  },
                  "seed": {
                    "type": "integer",
                    "description": "Random seed for reproducible results.",
                    "default": 1
                  },
                  "model": {
                    "type": "string",
                    "description": "The model variant to use.",
                    "default": "gen4_image"
                  },
                  "referenceImages": {
                    "type": "array",
                    "description": "An array of up to three images to be used as references. At least one item is required. `referenceImages` is required.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "uri": {
                          "type": "string"
                        },
                        "tag": {
                          "type": "string"
                        }
                      }
                    },
                    "default": [
                      {
                        "uri": "https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg",
                        "tag": "style_ref"
                      }
                    ]
                  },
                  "contentModeration": {
                    "type": "object",
                    "required": [
                      "publicFigureThreshold"
                    ],
                    "properties": {
                      "publicFigureThreshold": {
                        "type": "string",
                        "description": "Threshold for public-figure detection. Use `auto` for default behavior."
                      }
                    },
                    "default": {
                      "publicFigureThreshold": "auto"
                    }
                  }
                },
                "default": {
                  "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"
                  }
                }
              },
              "examples": {
                "Validated request": {
                  "summary": "Validated request",
                  "value": {
                    "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"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "example": {
                    "id": "31f9c5b2-ea5c-421c-8044-75a6bb53211d"
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/runwayml/v1/text_to_image \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n      \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n      \"ratio\": \"1280:720\",\n      \"model\": \"gen4_image\",\n      \"referenceImages\": [\n        {\n          \"uri\": \"https://your-image-host/reference.jpg\",\n          \"tag\": \"ref\"\n        }\n      ]\n    }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/runwayml/v1/text_to_image\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n            \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n            \"ratio\": \"1280:720\",\n            \"model\": \"gen4_image\",\n            \"referenceImages\": [\n                    {\n                            \"uri\": \"https://your-image-host/reference.jpg\",\n                            \"tag\": \"ref\"\n                    }\n            ]\n    },\n)\n\ntask = response.json()\nprint(task[\"id\"])  # poll GET /runwayml/v1/tasks/{id} until the output array appears\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\"https://api.cometapi.com/runwayml/v1/text_to_image\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n            \"promptText\": \"A paper boat floating on calm water at sunrise.\",\n            \"ratio\": \"1280:720\",\n            \"model\": \"gen4_image\",\n            \"referenceImages\": [\n                {\n                    \"uri\": \"https://your-image-host/reference.jpg\",\n                    \"tag\": \"ref\"\n                }\n            ]\n        }),\n});\n\nconst task = await response.json();\nconsole.log(task.id); // poll GET /runwayml/v1/tasks/{id} until the output array appears\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
