> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Runway テキストから動画タスクを作成

> CometAPI を通じて Runway Gen-4.5 でテキストプロンプトから動画を生成します。

`gen4.5` を使用して、テキストプロンプトから動画を生成します。CometAPI API
キーを Bearer 認証と JSON リクエスト本文とともに送信します。

## リクエストを準備する

* `model` を `gen4.5` に設定します。
* `promptText` で、1～1,000 UTF-16 コードユニットを使用してシーンと動きを説明します。
* `ratio` を、横向きの場合は `1280:720`、縦向きの場合は `720:1280` に設定します。
* `duration` を `2` ～ `10` 秒の整数に設定します。

4つのフィールドはすべて必須です。画像から開始するには、
[Runway 画像から動画タスクを作成](./runway-images-raw-video).
このテキストから動画へのリクエストには、`promptImage` または `audio` トグルを含めないでください。

## オプションの制御を設定する

明示的なサンプリングシードには、`1` ～ `4294967295` を使用します。省略するか `0` を指定すると、
ランダムなシードが選択されます。`contentModeration` を含める場合は、その
`publicFigureThreshold` を `auto` または `low` に設定します。それ以外の場合はオブジェクトを省略します。

`outputFormat` を使用して、MP4、ProRes、PNG シーケンス、または HDR
リクエストスキーマに記載された形式を選択します。H.264 MP4 の場合は省略します。設定できるのは
`proresProfile` が `outputFormat` または `prores` の場合に限られます。`hdr_prores`
HDR ProRes 形式では、`422`、`422 HQ`、または `4444` を使用できます。

## 結果を取得する

返された `id` を保存し、次を使用します。 [Runway タスクを取得する](./runway-to-get-task-details).
`status` が `SUCCEEDED` の場合、`output` 内の動画 URL を読み取ります。


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-generate-a-video-from-text.openapi.json POST /runwayml/v1/text_to_video
openapi: 3.1.0
info:
  title: Create a Runway text-to-video task
  version: 1.0.0
  description: Create a Runway text-to-video task through CometAPI.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/text_to_video:
    post:
      summary: Create a Runway text-to-video task
      description: >-
        Submit a JSON request and save the returned id. Use GET
        /runwayml/v1/tasks/{id} to retrieve the result.
      operationId: text_to_video
      requestBody:
        required: true
        content:
          application/json:
            schema:
              title: gen4.5
              type: object
              properties:
                model:
                  type: string
                  description: Model ID for this request variant.
                  const: gen4.5
                  enum:
                    - gen4.5
                promptText:
                  description: >-
                    Describe the requested scene or motion in 1 to 1,000 UTF-16
                    code units.
                  type: string
                  minLength: 1
                  maxLength: 1000
                ratio:
                  description: >-
                    Requested output dimensions, expressed as width:height.
                    Choose a value listed for this model and endpoint.
                  type: string
                  enum:
                    - '1280:720'
                    - '720:1280'
                duration:
                  description: >-
                    Requested video duration in whole seconds, from 2 through
                    10.
                  type: integer
                  minimum: 2
                  maximum: 10
                seed:
                  type: integer
                  minimum: 0
                  maximum: 4294967295
                  description: >-
                    Optional sampling seed. Use a positive integer for an
                    explicit seed. Omission or 0 selects a random seed.
                contentModeration:
                  type: object
                  description: >-
                    Optional content moderation settings. Omit the object to use
                    standard moderation.
                  properties:
                    publicFigureThreshold:
                      type: string
                      description: >-
                        Use auto for standard moderation or low for less
                        restrictive public-figure filtering.
                      enum:
                        - auto
                        - low
                  required:
                    - publicFigureThreshold
                  additionalProperties: false
                outputFormat:
                  description: >-
                    Output encoding. Omit for mp4 (H.264). prores returns MOV;
                    png_sequence returns a PNG ZIP; sdr_rec709_10bit returns
                    10-bit Rec.709 HEVC. hdr10 and hlg return 10-bit HDR MP4;
                    hdr_pq_12bit_master returns 12-bit HEVC MOV; hdr_prores
                    returns HDR ProRes MOV. The HDR PNG/EXR sequence formats
                    return ZIP archives; the ACEScg variants target the named
                    ACES version.
                  type: string
                  enum:
                    - mp4
                    - prores
                    - png_sequence
                    - hdr10
                    - hlg
                    - sdr_rec709_10bit
                    - hdr_pq_12bit_master
                    - hdr_prores
                    - hdr_png_sequence
                    - hdr_exr_sequence
                    - hdr_exr_acescg_sequence_1_3
                    - hdr_exr_acescg_sequence_2_0
                proresProfile:
                  description: >-
                    Profile for outputFormat prores or hdr_prores. Omit for 4444
                    with prores, or 422 HQ with hdr_prores. hdr_prores accepts
                    only 422, 422 HQ, or 4444. Omit this field for other
                    formats.
                  type: string
                  enum:
                    - '422'
                    - '4444'
                    - 422 Proxy
                    - 422 LT
                    - 422 HQ
                    - 4444 XQ
              required:
                - promptText
                - ratio
                - duration
                - model
              allOf:
                - if:
                    required:
                      - proresProfile
                  then:
                    required:
                      - outputFormat
                    properties:
                      outputFormat:
                        type: string
                        description: Output format when proresProfile is supplied.
                        enum:
                          - prores
                          - hdr_prores
                - if:
                    required:
                      - outputFormat
                    properties:
                      outputFormat:
                        const: hdr_prores
                        description: HDR ProRes output.
                  then:
                    properties:
                      proresProfile:
                        type: string
                        description: Profile supported by HDR ProRes.
                        enum:
                          - '422'
                          - 422 HQ
                          - '4444'
              additionalProperties: false
              description: Request parameters for gen4.5.
            examples:
              Gen-4.5:
                summary: Gen-4.5
                value:
                  model: gen4.5
                  promptText: A paper boat drifts on calm water at sunrise.
                  ratio: '1280:720'
                  duration: 5
      responses:
        '200':
          description: Task submitted. Save its id to retrieve task status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Task ID for GET /runwayml/v1/tasks/{id}.
                  status:
                    type: string
                    description: Task state, when returned.
                  createdAt:
                    type: string
                    description: Task submission timestamp, when returned.
                    format: date-time
                  output:
                    type: array
                    description: Result URLs, when returned.
                    items:
                      type: string
                      format: uri
                  failure:
                    type: string
                    description: Failure explanation, when returned.
                  failureCode:
                    type: string
                    description: Machine-readable failure code, when returned.
                  estimatedCost:
                    type: object
                    description: Task estimate metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                  cost:
                    type: object
                    description: Task cost metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                required:
                  - id
                additionalProperties: false
              example:
                id: 00000000-0000-4000-8000-000000000001
        '400':
          description: Invalid request or unavailable task ID.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    description: Task request error.
                    properties:
                      code:
                        type:
                          - string
                          - integer
                        description: Machine-readable task error code.
                      message:
                        type: string
                        description: Error explanation.
                      data:
                        description: Additional error details, when returned.
                    required:
                      - code
                      - message
                    additionalProperties: true
                  - type: object
                    description: Request authentication or validation error.
                    properties:
                      error:
                        type: object
                        description: Error details.
                        properties:
                          message:
                            type: string
                            description: Error explanation.
                          type:
                            type: string
                            description: Error category.
                          code:
                            type:
                              - string
                              - integer
                              - 'null'
                            description: Error code, when returned.
                        required:
                          - message
                        additionalProperties: true
                    required:
                      - error
                    additionalProperties: true
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                type: object
                description: Request authentication or validation error.
                properties:
                  error:
                    type: object
                    description: Error details.
                    properties:
                      message:
                        type: string
                        description: Error explanation.
                      type:
                        type: string
                        description: Error category.
                      code:
                        type:
                          - string
                          - integer
                          - 'null'
                        description: Error code, when returned.
                    required:
                      - message
                    additionalProperties: true
                required:
                  - error
                additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: Gen-4.5
          source: |
            curl "https://api.cometapi.com/runwayml/v1/text_to_video" \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "gen4.5",
              "promptText": "A paper boat drifts on calm water at sunrise.",
              "ratio": "1280:720",
              "duration": 5
            }'
        - lang: Python
          label: Gen-4.5
          source: |
            import os
            import requests

            payload = {'model': 'gen4.5',
             'promptText': 'A paper boat drifts on calm water at sunrise.',
             'ratio': '1280:720',
             'duration': 5}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_video",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
                timeout=60,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: Gen-4.5
          source: |
            const payload = {
              "model": "gen4.5",
              "promptText": "A paper boat drifts on calm water at sunrise.",
              "ratio": "1280:720",
              "duration": 5
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_video",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            console.log((await response.json()).id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use your CometAPI API key.

````