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

# Websocket TTS

> Real-time text-to-speech streaming over websockets. Send text incrementally and receive audio chunks as they are generated. To authenticate, you must include an `Authorization` header, with the value `Bearer {API_TOKEN}`. You can also include an `apiKey` query param with the value being your API key. Websockets can run multiple TTS streams concurrently. If you're using the `contextId` feature, make sure all generations for the context are on the same websocket.




## AsyncAPI

````yaml api-reference/asyncapi.yaml channelOne
id: channelOne
title: Vogent Websocket
description: >-
  Real-time text-to-speech streaming over websockets. Send text incrementally
  and receive audio chunks as they are generated. To authenticate, you must
  include an `Authorization` header, with the value `Bearer {API_TOKEN}`. You
  can also include an `apiKey` query param with the value being your API key.
  Websockets can run multiple TTS streams concurrently. If you're using the
  `contextId` feature, make sure all generations for the context are on the same
  websocket.
servers:
  - id: vogent
    protocol: wss
    host: api.vogent.ai/api/tts/websocket
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_1
    id: sendWebsocketInput
    title: Send websocket input
    type: receive
    messages:
      - &ref_3
        id: WebsocketInput
        payload:
          - name: Websocket Input
            description: Input message for text-to-speech generation
            type: object
            properties:
              - name: generationId
                type: string
                description: Unique identifier for the generation request.
                required: true
              - name: contextId
                type: string
                description: >
                  A context that can represent a single conversation, helps
                  preserve voice consistency across multiple lines. Leave blank
                  if you don't need this behavior. Ignored after the first time
                  this generationId is seen. You may not have different voices
                  across the same context (all generations with the same
                  contextId, must also have the same voiceId).
                required: false
              - name: items
                type: string
                required: false
              - name: description
                type: string
                description: >
                  **Ignore the type above, this is an array.** An array of
                  {"optionId": string, "value": string} objects (a
                  ModelOptionValue object)
                required: false
              - name: voiceId
                type: string
                description: >-
                  ID of the voice to use for generation. Required the first time
                  this generationId is sent.
                required: false
              - name: text
                type: string
                description: Text content to convert to speech.
                required: false
              - name: finalText
                type: boolean
                description: Whether this is the final text chunk.
                required: false
              - name: cancel
                type: boolean
                description: Whether to cancel the generation with generationId.
                required: false
              - name: sampleRate
                type: integer
                description: >-
                  Sample rate for the generated audio. Required the first time
                  this generationId is sent.
                required: false
              - name: addWordTimestamps
                type: boolean
                description: Add timestamps on the audio for each word in the input.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            generationId:
              type: string
              description: Unique identifier for the generation request.
              x-parser-schema-id: <anonymous-schema-2>
            contextId:
              type: string
              description: >
                A context that can represent a single conversation, helps
                preserve voice consistency across multiple lines. Leave blank if
                you don't need this behavior. Ignored after the first time this
                generationId is seen. You may not have different voices across
                the same context (all generations with the same contextId, must
                also have the same voiceId).
              x-parser-schema-id: <anonymous-schema-3>
            voiceOptionValues:
              items:
                type: string
              description: >
                **Ignore the type above, this is an array.** An array of
                {"optionId": string, "value": string} objects (a
                ModelOptionValue object)
              x-parser-schema-id: <anonymous-schema-4>
            voiceId:
              type: string
              description: >-
                ID of the voice to use for generation. Required the first time
                this generationId is sent.
              x-parser-schema-id: <anonymous-schema-5>
            text:
              type: string
              description: Text content to convert to speech.
              x-parser-schema-id: <anonymous-schema-6>
            finalText:
              type: boolean
              description: Whether this is the final text chunk.
              x-parser-schema-id: <anonymous-schema-7>
            cancel:
              type: boolean
              description: Whether to cancel the generation with generationId.
              x-parser-schema-id: <anonymous-schema-8>
            sampleRate:
              type: integer
              description: >-
                Sample rate for the generated audio. Required the first time
                this generationId is sent.
              x-parser-schema-id: <anonymous-schema-9>
            addWordTimestamps:
              type: boolean
              description: Add timestamps on the audio for each word in the input.
              x-parser-schema-id: <anonymous-schema-10>
          required:
            - generationId
          x-parser-schema-id: <anonymous-schema-1>
        title: Websocket Input
        description: Input message for text-to-speech generation
        example: |-
          {
            "generationId": "<string>",
            "contextId": "<string>",
            "items": "<string>",
            "description": "<string>",
            "voiceId": "<string>",
            "text": "<string>",
            "finalText": true,
            "cancel": true,
            "sampleRate": 123,
            "addWordTimestamps": true
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: WebsocketInput
          - id: x-parser-message-name
            value: WebsocketInput
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: channelOne
  - &ref_2
    id: receiveWebsocketOutput
    title: Receive websocket output
    type: send
    messages:
      - &ref_4
        id: FinishedMessage
        payload:
          - name: Finished Message
            description: Message sent when text-to-speech generation is complete
            type: object
            properties:
              - name: type
                type: string
                description: Message type, always "finished"
                enumValues:
                  - finished
                required: true
              - name: generationId
                type: string
                description: Unique identifier for the generation request
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - finished
              description: Message type, always "finished"
              x-parser-schema-id: <anonymous-schema-12>
            generationId:
              type: string
              description: Unique identifier for the generation request
              x-parser-schema-id: <anonymous-schema-13>
          required:
            - type
            - generationId
          x-parser-schema-id: <anonymous-schema-11>
        title: Finished Message
        description: Message sent when text-to-speech generation is complete
        example: |-
          {
            "type": "<string>",
            "generationId": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: FinishedMessage
          - id: x-parser-message-name
            value: FinishedMessage
      - &ref_5
        id: ErrorMessage
        payload:
          - name: Error Message
            description: Message sent when text-to-speech generation encounters an error
            type: object
            properties:
              - name: type
                type: string
                description: Message type, always "error"
                enumValues:
                  - error
                required: true
              - name: generationId
                type: string
                description: Unique identifier for the generation request
                required: true
              - name: error
                type: string
                description: Error message describing what went wrong
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - error
              description: Message type, always "error"
              x-parser-schema-id: <anonymous-schema-15>
            generationId:
              type: string
              description: Unique identifier for the generation request
              x-parser-schema-id: <anonymous-schema-16>
            error:
              type: string
              description: Error message describing what went wrong
              x-parser-schema-id: <anonymous-schema-17>
          required:
            - type
            - generationId
            - error
          x-parser-schema-id: <anonymous-schema-14>
        title: Error Message
        description: Message sent when text-to-speech generation encounters an error
        example: |-
          {
            "type": "<string>",
            "generationId": "<string>",
            "error": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ErrorMessage
          - id: x-parser-message-name
            value: ErrorMessage
      - &ref_6
        id: ChunkMessage
        payload:
          - name: Chunk Message
            description: >-
              Message sent with audio data chunks during text-to-speech
              generation
            type: object
            properties:
              - name: type
                type: string
                description: Message type, always "chunk"
                enumValues:
                  - chunk
                required: true
              - name: generationId
                type: string
                description: Unique identifier for the generation request
                required: true
              - name: audio
                type: string
                description: Base64-encoded audio data chunk
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - chunk
              description: Message type, always "chunk"
              x-parser-schema-id: <anonymous-schema-19>
            generationId:
              type: string
              description: Unique identifier for the generation request
              x-parser-schema-id: <anonymous-schema-20>
            audio:
              type: string
              description: Base64-encoded audio data chunk
              x-parser-schema-id: <anonymous-schema-21>
          required:
            - type
            - generationId
            - audio
          x-parser-schema-id: <anonymous-schema-18>
        title: Chunk Message
        description: Message sent with audio data chunks during text-to-speech generation
        example: |-
          {
            "type": "<string>",
            "generationId": "<string>",
            "audio": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ChunkMessage
          - id: x-parser-message-name
            value: ChunkMessage
      - &ref_7
        id: TimestampMessage
        payload:
          - name: Timestamp Message
            description: >-
              Message sent with timestamps during text-to-speech generation,
              only when add word timestamps is true
            type: object
            properties:
              - name: alignment
                type: object
                required: true
                properties:
                  - name: words
                    type: array
                    description: >-
                      An array of strings representing the words in this
                      alignment chunk
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: startTimes
                    type: array
                    description: >-
                      The start time of each word (the array will be the same
                      length as words). Relative to the start of the generation,
                      in milliseconds.
                    required: false
                    properties:
                      - name: item
                        type: integer
                        required: false
                  - name: durationMs
                    type: array
                    description: >-
                      The duration of each word (the array will be the same
                      length as words)
                    required: false
                    properties:
                      - name: item
                        type: integer
                        required: false
              - name: type
                type: string
                description: Message type, always "alignment"
                enumValues:
                  - alignment
                required: true
              - name: generationId
                type: string
                description: Unique identifier for the generation request
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            alignment:
              type: object
              properties:
                words:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-25>
                  description: >-
                    An array of strings representing the words in this alignment
                    chunk
                  x-parser-schema-id: <anonymous-schema-24>
                startTimes:
                  type: array
                  items:
                    type: integer
                    x-parser-schema-id: <anonymous-schema-27>
                  description: >-
                    The start time of each word (the array will be the same
                    length as words). Relative to the start of the generation,
                    in milliseconds.
                  x-parser-schema-id: <anonymous-schema-26>
                durationMs:
                  type: array
                  items:
                    type: integer
                    x-parser-schema-id: <anonymous-schema-29>
                  description: >-
                    The duration of each word (the array will be the same length
                    as words)
                  x-parser-schema-id: <anonymous-schema-28>
              x-parser-schema-id: <anonymous-schema-23>
            type:
              type: string
              enum:
                - alignment
              description: Message type, always "alignment"
              x-parser-schema-id: <anonymous-schema-30>
            generationId:
              type: string
              description: Unique identifier for the generation request
              x-parser-schema-id: <anonymous-schema-31>
          required:
            - type
            - alignment
            - generationId
          x-parser-schema-id: <anonymous-schema-22>
        title: Timestamp Message
        description: >-
          Message sent with timestamps during text-to-speech generation, only
          when add word timestamps is true
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: TimestampMessage
          - id: x-parser-message-name
            value: TimestampMessage
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
receiveMessages:
  - *ref_4
  - *ref_5
  - *ref_6
  - *ref_7
extensions:
  - id: x-parser-unique-object-id
    value: channelOne
securitySchemes: []

````