> ## 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.

# Tạo tác vụ text-to-video Runway

> Tạo video từ Prompt văn bản bằng Runway Gen-4.5 thông qua CometAPI.

Sử dụng `gen4.5` để tạo video từ một Prompt văn bản. Gửi CometAPI API
key của bạn bằng phương thức xác thực Bearer và phần thân yêu cầu JSON.

## Chuẩn bị yêu cầu

* Đặt `model` thành `gen4.5`.
* Mô tả cảnh và chuyển động trong `promptText`, sử dụng từ 1 đến 1.000 đơn vị mã UTF-16.
* Đặt `ratio` thành `1280:720` cho bố cục ngang hoặc `720:1280` cho bố cục dọc.
* Đặt `duration` thành một số nguyên từ `2` đến `10` giây.

Cả bốn trường đều bắt buộc. Để bắt đầu từ một hình ảnh, hãy sử dụng
[Tạo tác vụ image-to-video Runway](https://apidoc.cometapi.com/vi/api/video/runway/official-format/runway-images-raw-video.md).
Không đưa `promptImage` hoặc tùy chọn `audio` vào yêu cầu text-to-video này.

## Thiết lập các tùy chọn điều khiển

Để chỉ định seed lấy mẫu rõ ràng, hãy dùng `1` đến `4294967295`. Việc bỏ qua hoặc `0`
sẽ chọn một seed ngẫu nhiên. Nếu bạn đưa `contentModeration` vào, hãy đặt giá trị của thuộc tính đó
`publicFigureThreshold` thành `auto` hoặc `low`; nếu không, hãy bỏ qua đối tượng.

Sử dụng `outputFormat` để chọn MP4, ProRes, chuỗi PNG hoặc một trong các định dạng HDR
được liệt kê trong schema yêu cầu. Bỏ qua trường này để dùng H.264 MP4. Bạn có thể đặt
`proresProfile` chỉ khi `outputFormat` là `prores` hoặc `hdr_prores`.
Định dạng HDR ProRes chấp nhận `422`, `422 HQ` hoặc `4444`.

## Lấy kết quả

Lưu `id` được trả về và sử dụng [Lấy tác vụ Runway](https://apidoc.cometapi.com/vi/api/video/runway/official-format/runway-to-get-task-details.md).
Khi `status` là `SUCCEEDED`, hãy đọc các URL video trong `output`.


## 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.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.