> ## 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 giọng nói Runway từ văn bản

> Chuyển đổi văn bản thành giọng nói bằng giọng nói cài sẵn hoặc âm thanh tham chiếu qua Runway API.

Sử dụng `POST /runwayml/v1/text_to_speech` để tạo tác vụ giọng nói từ văn bản.
Gửi khóa CometAPI API của bạn bằng phương thức xác thực Bearer và nội dung yêu cầu JSON.

## Chọn một mô hình và giọng nói

Mọi yêu cầu đều cần `model` và `promptText`. Trường `voice` là bắt buộc
cho `eleven_multilingual_v2`, `eleven_v3` và `eleven_v4`, và không bắt buộc cho `seed_audio`.

| ID mô hình | Giới hạn văn bản | Cấu hình giọng nói |
| - | - | - |
| `eleven_multilingual_v2` | 1000 đơn vị mã UTF-16 | `type: runway-preset` và `presetId`, chẳng hạn như `Maya` |
| `eleven_v3` | 5000 ký tự | `type: runway-preset` và `presetId`, chẳng hạn như `Maya` |
| `eleven_v4` | Văn bản không rỗng | `type: runway-preset` và `presetId`, chẳng hạn như `Maya` |
| `seed_audio` | 2048 ký tự | Bỏ qua `voice` để dùng giọng nói mặc định, hoặc sử dụng `type: reference-audio` và một `audioUri` |

Đối với giọng nói cài sẵn, hãy chọn `presetId` trong schema yêu cầu. Đối với `seed_audio`,
thay thế `audioUri` ví dụ bằng URL HTTPS có thể truy cập của mẫu tham chiếu giọng nói của bạn.

## Điều chỉnh biểu cảm giọng nói

Với `eleven_v3`, `promptText` có thể bao gồm các thẻ biểu cảm như `[whispers]`
hoặc `[laughs]`. Mô hình cũng chấp nhận các tùy chọn điều khiển này:

| Trường | Giá trị | Ý nghĩa |
| - | - | - |
| `stability` | Số từ 0 đến 1 | Các giá trị khác 0 thấp hơn cho phép biểu cảm nhiều hơn; các giá trị cao hơn ổn định hơn. |
| `similarityBoost` | Số từ 0 đến 1 | Các giá trị cao hơn bám sát giọng nói đã chọn hơn. |
| `style` | Số từ 0 đến 1 | Các giá trị cao hơn nhấn mạnh phong cách giọng nói. |
| `speed` | Số từ 0,7 đến 1,2 | `1` sử dụng tốc độ bình thường. |
| `useSpeakerBoost` | `true` | Yêu cầu mức độ tương đồng cao hơn với giọng nói đã chọn. |
| `languageCode` | Mã ngôn ngữ ISO 639-1 | Hướng dẫn cách phát âm và chuẩn hóa văn bản. |
| `applyTextNormalization` | `auto`, `on`, `off` | Kiểm soát cách văn bản như số được chuyển thành từ ngữ được đọc. |
| `seed` | Số nguyên từ 1 đến 4294967295 | Đặt seed lấy mẫu. |

Đối với `stability`, `similarityBoost` và `style`, giá trị `0` sử dụng giá trị mặc định của mô hình
mặc định, tương tự như khi bỏ qua trường này. `useSpeakerBoost: false` cũng sử dụng giá trị mặc định của mô hình
mặc định. Để đặt seed lấy mẫu, hãy dùng số nguyên dương; `seed: 0` chọn seed
tự động.

## Điều chỉnh giọng nói Eleven v4

Với `eleven_v4`, `promptText` hỗ trợ các thẻ biểu cảm như `[laughs]`,
`[whispers]`, và `[pause]`. Sử dụng các tùy chọn điều khiển không bắt buộc này:

| Trường | Giá trị | Ý nghĩa |
| - | - | - |
| `stability` | Số từ 0 đến 1 | Các giá trị thấp hơn cho phép phạm vi cảm xúc rộng hơn; các giá trị cao hơn ổn định hơn. |
| `similarityBoost` | Số từ 0 đến 1 | Đặt mức độ đầu ra bám sát giọng nói đã chọn. |
| `style` | Số từ 0 đến 1 | Các giá trị cao hơn khuếch đại phong cách người nói. |
| `speed` | Số từ 0,7 đến 1,2 | Giá trị dưới 1 làm chậm giọng nói; giá trị trên 1 làm tăng tốc. |
| `useSpeakerBoost` | `true` hoặc `false` | Tăng mức độ tương đồng với giọng nói đã chọn khi `true`. |
| `languageCode` | 2–16 ký tự | Ép buộc cách phát âm, chẳng hạn như `en` hoặc `pt-BR`. |
| `previousText` | Chuỗi | Tiếp tục giọng nói từ văn bản được tạo trước yêu cầu này. |
| `nextText` | Chuỗi | Dẫn giọng nói vào văn bản được tạo sau yêu cầu này. |
| `seed` | Số nguyên từ 0 đến 4294967295 | Chọn seed để có đầu ra nhất quán hơn. |

`eleven_v4` không sử dụng `applyTextNormalization`. Các trường `previousText` và
`nextText` hữu ích khi bạn tạo các phân đoạn liền kề và muốn mô hình duy trì sự
chuyển tiếp mạch lạc.

## Điều chỉnh tốc độ và định dạng giọng nói

Với `seed_audio`, sử dụng `speechRate` và `loudnessRate` trong khoảng từ -50 đến 100, hoặc
`pitchRate` trong khoảng từ -12 đến 12 nửa cung. Các tùy chọn điều khiển này chấp nhận số nguyên; việc bỏ qua
hoặc `0` sẽ giữ giá trị bình thường.

Đặt `sampleRate` thành `8000`, `16000`, `24000`, `32000`, `44100` hoặc `48000` Hz.
Đặt `outputFormat` thành `wav`, `mp3` hoặc `ogg_opus`. Không đưa `duration`,
`referenceAudios`, hoặc các tùy chọn điều khiển Eleven v3 cùng với `seed_audio` trên endpoint này.

## Truy xuất kết quả

Lưu `id` được trả về, rồi sử dụng [Lấy một tác vụ Runway](https://apidoc.cometapi.com/vi/api/video/runway/official-format/runway-to-get-task-details.md)
để truy xuất trạng thái tác vụ. Khi `status` là `SUCCEEDED`, hãy đọc các URL âm thanh trong
`output`. Nếu tác vụ thất bại, hãy kiểm tra `failure` và `failureCode`.


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-generate-speech-from-text.openapi.json POST /runwayml/v1/text_to_speech
openapi: 3.1.0
info:
  title: Generate Runway speech from text API
  version: 1.0.0
  description: >-
    Convert text into speech with a preset voice or reference audio using the
    Runway API.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/text_to_speech:
    post:
      summary: Generate Runway speech from text
      description: >-
        Convert text into speech with a preset voice or reference audio using
        the Runway API. Save the returned id and retrieve the task to obtain its
        output.
      operationId: runway_text_to_speech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - title: eleven_multilingual_v2
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_multilingual_v2
                      enum:
                        - eleven_multilingual_v2
                      description: Model ID for this request.
                    promptText:
                      description: Text to speak, from 1 to 1000 UTF-16 code units.
                      type: string
                      minLength: 1
                      maxLength: 1000
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_multilingual_v2.
                  default:
                    model: eleven_multilingual_v2
                    promptText: Welcome to our audio guide. Let us begin the tour.
                    voice:
                      type: runway-preset
                      presetId: Maya
                - title: eleven_v3
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_v3
                      enum:
                        - eleven_v3
                      description: Model ID for this request.
                    promptText:
                      description: >-
                        The text to convert to speech. You can include
                        expressive audio tags like [laughs] or [whispers] in the
                        script.
                      type: string
                      minLength: 1
                      maxLength: 5000
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                    stability:
                      description: >-
                        Voice stability from 0 to 1. Lower nonzero values allow
                        more expression; higher values are steadier. Omit or use
                        0 for the model default.
                      type: number
                      minimum: 0
                      maximum: 1
                    similarityBoost:
                      description: >-
                        Voice similarity from 0 to 1. Higher values follow the
                        selected voice more closely. Omit or use 0 for the model
                        default.
                      type: number
                      minimum: 0
                      maximum: 1
                    style:
                      description: >-
                        Style intensity from 0 to 1. Higher values emphasize the
                        selected voice style. Omit or use 0 for the model
                        default.
                      type: number
                      minimum: 0
                      maximum: 1
                    speed:
                      description: >-
                        Speech speed multiplier from 0.7 to 1.2. A value of 1
                        uses normal speed.
                      type: number
                      minimum: 0.7
                      maximum: 1.2
                    useSpeakerBoost:
                      description: >-
                        Set true to request greater similarity to the selected
                        voice. Omit or use false for the model default.
                      type: boolean
                    languageCode:
                      description: >-
                        ISO 639-1 language code to enforce pronunciation and
                        normalization.
                      type: string
                      minLength: 2
                      maxLength: 5
                    applyTextNormalization:
                      description: >-
                        How to normalize spoken text, such as reading numbers as
                        words: auto, on, or off.
                      type: string
                      enum:
                        - auto
                        - 'on'
                        - 'off'
                    seed:
                      description: >-
                        Sampling seed from 1 to 4294967295. Omit or use 0 for an
                        automatically chosen seed.
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_v3.
                  default:
                    model: eleven_v3
                    promptText: '[whispers] The adventure begins at sunrise.'
                    voice:
                      type: runway-preset
                      presetId: Maya
                    stability: 0.5
                    speed: 1
                - title: eleven_v4
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_v4
                      enum:
                        - eleven_v4
                      description: Model ID for this request.
                    promptText:
                      description: >-
                        The text to convert to speech. You can include
                        expressive audio tags like [laughs], [whispers], or
                        [pause] in the script.
                      type: string
                      minLength: 1
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                    stability:
                      description: >-
                        Voice stability from 0 to 1. Lower values allow broader
                        emotional range; higher values are steadier.
                      type: number
                      minimum: 0
                      maximum: 1
                    similarityBoost:
                      description: >-
                        How closely the output tracks the selected voice, from 0
                        to 1.
                      type: number
                      minimum: 0
                      maximum: 1
                    style:
                      description: >-
                        Style exaggeration from 0 to 1. Higher values amplify
                        the speaker style.
                      type: number
                      minimum: 0
                      maximum: 1
                    speed:
                      description: >-
                        Speech speed multiplier from 0.7 to 1.2. Values below 1
                        slow the speech down, and values above 1 speed it up.
                      type: number
                      minimum: 0.7
                      maximum: 1.2
                    useSpeakerBoost:
                      description: >-
                        Set true to boost similarity to the selected voice at a
                        small latency cost.
                      type: boolean
                    languageCode:
                      description: >-
                        Language code from 2 to 16 characters to enforce
                        pronunciation, such as en or pt-BR.
                      type: string
                      minLength: 2
                      maxLength: 16
                    seed:
                      description: >-
                        Optional seed from 0 to 4294967295 for more consistent
                        output.
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                    previousText:
                      description: >-
                        Text that comes before this request, so speech can
                        continue from an earlier generation.
                      type: string
                    nextText:
                      description: >-
                        Text that comes after this request, so speech can lead
                        into a later generation.
                      type: string
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_v4.
                  default:
                    model: eleven_v4
                    promptText: '[pause] The museum opens at nine.'
                    voice:
                      type: runway-preset
                      presetId: Maya
                    stability: 0.5
                    speed: 1
                    languageCode: en
                    previousText: The guide takes a breath.
                    nextText: Visitors enter through the west door.
                - title: seed_audio
                  type: object
                  properties:
                    model:
                      type: string
                      const: seed_audio
                      enum:
                        - seed_audio
                      description: Model ID for this request.
                    promptText:
                      description: Text to speak.
                      type: string
                      minLength: 1
                      maxLength: 2048
                    voice:
                      description: >-
                        Optional reference audio that supplies the speaking
                        voice. Omit this field to use a default voice.
                      title: SeedReferenceVoice
                      type: object
                      properties:
                        type:
                          type: string
                          const: reference-audio
                          enum:
                            - reference-audio
                          description: Input type. Use reference-audio.
                        audioUri:
                          description: >-
                            Audio input as an accessible HTTPS URL or base64
                            data URI.
                          anyOf:
                            - description: Accessible HTTPS URL of the audio file.
                              type: string
                              minLength: 13
                              maxLength: 2048
                              pattern: ^https:\/\/.*
                            - description: Base64 audio data URI, up to 5 MB.
                              type: string
                              minLength: 13
                              maxLength: 5242880
                              pattern: ^data:audio\/.*
                      required:
                        - type
                        - audioUri
                      additionalProperties: false
                    speechRate:
                      description: >-
                        Relative speech speed: negative values slow speech,
                        positive values speed it up. Omit or use 0 for normal
                        speed.
                      type: integer
                      minimum: -50
                      maximum: 100
                    loudnessRate:
                      description: >-
                        Relative loudness: negative values reduce volume,
                        positive values increase it. Omit or use 0 for normal
                        loudness.
                      type: integer
                      minimum: -50
                      maximum: 100
                    pitchRate:
                      description: >-
                        Pitch shift in semitones: negative values lower pitch,
                        positive values raise it. Omit or use 0 for unchanged
                        pitch.
                      type: integer
                      minimum: -12
                      maximum: 12
                    sampleRate:
                      description: Output sample rate in Hz.
                      type: integer
                      enum:
                        - 8000
                        - 16000
                        - 24000
                        - 32000
                        - 44100
                        - 48000
                    outputFormat:
                      description: Output audio container/format.
                      type: string
                      enum:
                        - wav
                        - mp3
                        - ogg_opus
                  required:
                    - promptText
                    - model
                  additionalProperties: false
                  description: Request settings for seed_audio.
                  default:
                    model: seed_audio
                    promptText: Welcome to our audio guide. Let us begin the tour.
                    voice:
                      type: reference-audio
                      audioUri: https://your-audio-host/voice-reference.mp3
                    sampleRate: 44100
                    outputFormat: mp3
              discriminator:
                propertyName: model
              default:
                model: eleven_multilingual_v2
                promptText: Welcome to our audio guide. Let us begin the tour.
                voice:
                  type: runway-preset
                  presetId: Maya
            examples:
              eleven_multilingual_v2:
                summary: eleven_multilingual_v2
                value:
                  model: eleven_multilingual_v2
                  promptText: Welcome to our audio guide. Let us begin the tour.
                  voice:
                    type: runway-preset
                    presetId: Maya
              eleven_v3:
                summary: eleven_v3
                value:
                  model: eleven_v3
                  promptText: '[whispers] The adventure begins at sunrise.'
                  voice:
                    type: runway-preset
                    presetId: Maya
                  stability: 0.5
                  speed: 1
              eleven_v4:
                summary: eleven_v4
                value:
                  model: eleven_v4
                  promptText: '[pause] The museum opens at nine.'
                  voice:
                    type: runway-preset
                    presetId: Maya
                  stability: 0.5
                  speed: 1
                  languageCode: en
                  previousText: The guide takes a breath.
                  nextText: Visitors enter through the west door.
              seed_audio:
                summary: seed_audio
                value:
                  model: seed_audio
                  promptText: Welcome to our audio guide. Let us begin the tour.
                  voice:
                    type: reference-audio
                    audioUri: https://your-audio-host/voice-reference.mp3
                  sampleRate: 44100
                  outputFormat: mp3
      responses:
        '200':
          description: Task created. Save the returned 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: 123e4567-e89b-42d3-a456-426614174000
        '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: eleven_multilingual_v2
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_multilingual_v2",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            }'
        - lang: Python
          label: eleven_multilingual_v2
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_multilingual_v2',
                'promptText': 'Welcome to our audio guide. Let us begin the tour.',
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'}}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_multilingual_v2
          source: |
            const payload = {
              "model": "eleven_multilingual_v2",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                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());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: eleven_v3
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_v3",
              "promptText": "[whispers] The adventure begins at sunrise.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1
            }'
        - lang: Python
          label: eleven_v3
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_v3',
                'promptText': '[whispers] The adventure begins at sunrise.',
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'},
                'stability': 0.5,
                'speed': 1}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_v3
          source: |
            const payload = {
              "model": "eleven_v3",
              "promptText": "[whispers] The adventure begins at sunrise.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                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());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: eleven_v4
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_v4",
              "promptText": "[pause] The museum opens at nine.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1,
              "languageCode": "en",
              "previousText": "The guide takes a breath.",
              "nextText": "Visitors enter through the west door."
            }'
        - lang: Python
          label: eleven_v4
          source: |
            import os
            import requests

            payload = {
                "model": "eleven_v4",
                "promptText": "[pause] The museum opens at nine.",
                "voice": {"type": "runway-preset", "presetId": "Maya"},
                "stability": 0.5,
                "speed": 1,
                "languageCode": "en",
                "previousText": "The guide takes a breath.",
                "nextText": "Visitors enter through the west door.",
            }

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_v4
          source: |
            const payload = {
              "model": "eleven_v4",
              "promptText": "[pause] The museum opens at nine.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1,
              "languageCode": "en",
              "previousText": "The guide takes a breath.",
              "nextText": "Visitors enter through the west door."
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                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());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: seed_audio
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "seed_audio",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "reference-audio",
                "audioUri": "https://your-audio-host/voice-reference.mp3"
              },
              "sampleRate": 44100,
              "outputFormat": "mp3"
            }'
        - lang: Python
          label: seed_audio
          source: |
            import os
            import requests

            payload = {   'model': 'seed_audio',
                'promptText': 'Welcome to our audio guide. Let us begin the tour.',
                'voice': {   'type': 'reference-audio',
                             'audioUri': 'https://your-audio-host/voice-reference.mp3'},
                'sampleRate': 44100,
                'outputFormat': 'mp3'}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: seed_audio
          source: |
            const payload = {
              "model": "seed_audio",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "reference-audio",
                "audioUri": "https://your-audio-host/voice-reference.mp3"
              },
              "sampleRate": 44100,
              "outputFormat": "mp3"
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                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());
            const task = await response.json();
            console.log(task.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.