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

# Text-to-Speech (WebSocket)

> Generate audio in realtime with contexts



## AsyncAPI

````yaml asyncapi.yml /tts/websocket
id: /tts/websocket
title: /tts/websocket
description: Generate audio in realtime with contexts
servers:
  - id: production
    protocol: wss
    host: api.cartesia.ai
    bindings: []
    variables: []
address: /tts/websocket
parameters:
  - id: cartesia_version
    jsonSchema:
      type: string
      description: API version, e.g. `2026-08-14`
    description: API version, e.g. `2026-08-14`
    type: string
    required: true
    deprecated: false
bindings: []
operations:
  - &ref_3
    id: sendTTSGeneration
    title: Send t t s generation
    type: receive
    messages:
      - &ref_5
        id: generationRequest
        payload:
          - name: Generation Request
            description: Use this to generate speech for a transcript.
            type: object
            properties:
              - name: model_id
                type: string
                description: >-
                  The ID of the model to use for the generation. See
                  [Models](/build-with-cartesia/tts-models/latest) for all
                  options.
                enumValues:
                  - sonic-3.6
                  - sonic-3.5
                  - sonic-3
                  - sonic-latest
                required: true
              - name: transcript
                type: string
                description: >-
                  Transcript chunk to add to the audio being generated by this
                  context.
                required: true
              - name: voice
                type: oneOf
                description: >-
                  The voice to use for generation. Pass either a voice ID string
                  or an object with a required `id` (additional object fields
                  may be added in future API versions). Use the same value for
                  all generation requests made to the same context. Embeddings
                  are not accepted in this API version.
                required: true
                properties:
                  - name: id
                    type: string
                    description: The ID of the voice.
                    required: true
              - name: output_format
                type: object
                description: >-
                  Audio output format configuration. Use the same value for all
                  generation requests made to the same context.
                required: true
                properties:
                  - name: container
                    type: string
                    description: Audio container format
                    enumValues:
                      - raw
                    required: true
                  - name: encoding
                    type: string
                    description: >-
                      Audio encoding format. See [TTS Output Audio
                      Format](/build-with-cartesia/capability-guides/tts-output-audio-format)
                      if you're unsure what to use.
                    enumValues:
                      - pcm_f32le
                      - pcm_s16le
                      - pcm_mulaw
                      - pcm_alaw
                    required: true
                  - name: sample_rate
                    type: integer
                    description: Audio sample rate in Hz.
                    enumValues:
                      - 8000
                      - 16000
                      - 22050
                      - 24000
                      - 44100
                      - 48000
                    required: true
              - name: language
                type: string
                description: >-
                  The transcript's language or locale. Use a base language code
                  such as `en` or a regional locale code such as `en-GB`.
                  `language` and `locale` accept the same values. Set one or the
                  other, never both; setting both returns an error. The enum
                  lists canonical codes; matching is case-insensitive, and
                  underscore locale aliases such as `en_GB` are also accepted.
                  See [supported
                  codes](/build-with-cartesia/capability-guides/advanced-capabilities#which-locales-are-supported).
                enumValues:
                  - en
                  - fr
                  - de
                  - es
                  - pt
                  - zh
                  - ja
                  - hi
                  - it
                  - ko
                  - nl
                  - pl
                  - ru
                  - sv
                  - tr
                  - tl
                  - bg
                  - ro
                  - ar
                  - cs
                  - el
                  - fi
                  - hr
                  - ms
                  - sk
                  - da
                  - ta
                  - uk
                  - hu
                  - 'no'
                  - vi
                  - bn
                  - th
                  - he
                  - ka
                  - id
                  - te
                  - gu
                  - kn
                  - ml
                  - mr
                  - pa
                  - or
                  - ur
                  - bg-BG
                  - bn-IN
                  - cs-CZ
                  - da-DK
                  - de-DE
                  - el-GR
                  - en-AU
                  - en-CA
                  - en-GB
                  - en-IE
                  - en-IN
                  - en-NZ
                  - en-SG
                  - en-US
                  - en-ZA
                  - es-ES
                  - es-MX
                  - es-US
                  - fi-FI
                  - fr-CA
                  - fr-FR
                  - gu-IN
                  - he-IL
                  - hi-IN
                  - hr-HR
                  - hu-HU
                  - id-ID
                  - it-IT
                  - ja-JP
                  - ka-GE
                  - kn-IN
                  - ko-KR
                  - ml-IN
                  - mr-IN
                  - ms-MY
                  - nl-BE
                  - nl-NL
                  - no-NO
                  - or-IN
                  - pa-IN
                  - pl-PL
                  - pt-BR
                  - pt-PT
                  - ro-RO
                  - ru-RU
                  - sk-SK
                  - sv-SE
                  - ta-IN
                  - te-IN
                  - th-TH
                  - tl-PH
                  - tr-TR
                  - uk-UA
                  - ur-IN
                  - vi-VN
                  - zh-CN
                required: false
              - name: locale
                type: string
                description: >-
                  The transcript's language or locale. Use a base language code
                  such as `en` or a regional locale code such as `en-GB`.
                  `language` and `locale` accept the same values. Set one or the
                  other, never both; setting both returns an error. The enum
                  lists canonical codes; matching is case-insensitive, and
                  underscore locale aliases such as `en_GB` are also accepted.
                  See [supported
                  codes](/build-with-cartesia/capability-guides/advanced-capabilities#which-locales-are-supported).
                enumValues:
                  - en
                  - fr
                  - de
                  - es
                  - pt
                  - zh
                  - ja
                  - hi
                  - it
                  - ko
                  - nl
                  - pl
                  - ru
                  - sv
                  - tr
                  - tl
                  - bg
                  - ro
                  - ar
                  - cs
                  - el
                  - fi
                  - hr
                  - ms
                  - sk
                  - da
                  - ta
                  - uk
                  - hu
                  - 'no'
                  - vi
                  - bn
                  - th
                  - he
                  - ka
                  - id
                  - te
                  - gu
                  - kn
                  - ml
                  - mr
                  - pa
                  - or
                  - ur
                  - bg-BG
                  - bn-IN
                  - cs-CZ
                  - da-DK
                  - de-DE
                  - el-GR
                  - en-AU
                  - en-CA
                  - en-GB
                  - en-IE
                  - en-IN
                  - en-NZ
                  - en-SG
                  - en-US
                  - en-ZA
                  - es-ES
                  - es-MX
                  - es-US
                  - fi-FI
                  - fr-CA
                  - fr-FR
                  - gu-IN
                  - he-IL
                  - hi-IN
                  - hr-HR
                  - hu-HU
                  - id-ID
                  - it-IT
                  - ja-JP
                  - ka-GE
                  - kn-IN
                  - ko-KR
                  - ml-IN
                  - mr-IN
                  - ms-MY
                  - nl-BE
                  - nl-NL
                  - no-NO
                  - or-IN
                  - pa-IN
                  - pl-PL
                  - pt-BR
                  - pt-PT
                  - ro-RO
                  - ru-RU
                  - sk-SK
                  - sv-SE
                  - ta-IN
                  - te-IN
                  - th-TH
                  - tl-PH
                  - tr-TR
                  - uk-UA
                  - ur-IN
                  - vi-VN
                  - zh-CN
                required: false
              - name: accent
                type: string
                description: >-
                  Usually unnecessary: Cartesia picks the closest accent the
                  voice supports for the requested `language` or `locale`. Set
                  it only to make a [multilingual
                  voice](/build-with-cartesia/capability-guides/multilingual-voices)
                  sound accented (e.g. speak English with a French accent). Must
                  come from the voice's [Get Voice `accents`
                  field](/api-reference/voices/get#response-accents). Learn more
                  [here](/build-with-cartesia/capability-guides/multilingual-voices#using-a-multilingual-voice).
                required: false
              - name: normalization
                type: string
                description: >-
                  Text normalization. `auto` (initial default) runs the
                  locale-aware normalizer, `off` skips it, or pass a language or
                  locale code (for example `en` or `en-IN`) to pin the
                  normalizer independently of the generation language. If
                  omitted on a later request in the same context, the previous
                  value is reused. See [Text
                  Normalization](/build-with-cartesia/capability-guides/text-normalization).
                required: false
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
              - name: continue
                type: boolean
                description: >
                  Whether `transcript` may be followed by more text:
                    - Set to `true` if you will add more `transcript` chunks to this context
                    - Set to `false` on the last `transcript` chunk for this context to minimize latency

                  Defaults to `false`


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details
                required: false
              - name: max_buffer_delay_ms
                type: integer
                description: >
                  The maximum time in milliseconds to buffer text before
                  starting generation. Values between [0, 5000]ms are supported.
                  Defaults to 3000ms.


                  See [Buffering](/use-the-api/tts-websocket/buffering) for
                  details
                required: false
              - name: flush
                type: boolean
                description: >
                  Whether to flush the context


                  See [Context
                  Flushing](/use-the-api/tts-websocket/context-flushing-and-flush-i-ds)
                  for details
                required: false
              - name: add_timestamps
                type: boolean
                description: >
                  Whether to include word-level timestamps for the generated
                  audio
                required: false
              - name: add_phoneme_timestamps
                type: boolean
                description: >
                  Whether to include phoneme-level timestamps for the generated
                  audio
                required: false
              - name: use_normalized_timestamps
                type: boolean
                description: >-
                  Whether to use normalized timestamps (`true`) or original
                  timestamps (`false`)
                required: false
              - name: pronunciation_dict_id
                type: string
                description: >-
                  The ID of a pronunciation dictionary to use for the generation

                  See [Custom
                  Pronunciations](/build-with-cartesia/capability-guides/custom-pronunciations)
                  for details
                required: false
              - name: generation_config
                type: object
                description: >-
                  Configure the various attributes of the generated speech

                  See [Volume, Speed, and
                  Emotion](/build-with-cartesia/capability-guides/volume-speed-emotion)
                  for details
                required: false
                properties:
                  - name: volume
                    type: number
                    description: >-
                      Adjust the volume of the generated speech between 0.5x and
                      2.0x the default volume. Valid values are between [0.5,
                      2.0] inclusive.
                    required: false
                  - name: speed
                    type: number
                    description: >-
                      Adjust the speed of the generated speech between 0.6x and
                      1.5x the default speed. Valid values are between [0.6,
                      1.5] inclusive.
                    required: false
                  - name: emotion
                    type: string
                    title: Emotion
                    description: >-
                      Optional. If omitted, the model interprets the emotional
                      subtext of the transcript. Must match a valid option
                      exactly.

                      A complete list can be found on the [Volume, Speed, and
                      Emotion](/build-with-cartesia/capability-guides/volume-speed-emotion)
                      page.
                    enumValues:
                      - neutral
                      - calm
                      - angry
                      - content
                      - sad
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - model_id
            - transcript
            - voice
            - output_format
            - context_id
          properties:
            model_id:
              type: string
              enum:
                - sonic-3.6
                - sonic-3.5
                - sonic-3
                - sonic-latest
              example: sonic-3.6
              description: >-
                The ID of the model to use for the generation. See
                [Models](/build-with-cartesia/tts-models/latest) for all
                options.
              x-parser-schema-id: <anonymous-schema-2>
            transcript:
              type: string
              description: >-
                Transcript chunk to add to the audio being generated by this
                context.
              x-parser-schema-id: <anonymous-schema-3>
            voice:
              description: >-
                The voice to use for generation. Pass either a voice ID string
                or an object with a required `id` (additional object fields may
                be added in future API versions). Use the same value for all
                generation requests made to the same context. Embeddings are not
                accepted in this API version.
              oneOf:
                - type: string
                  title: TTSRequestVoiceId
                  description: The ID of the voice.
                  example: a0e99841-438c-4a64-b679-ae501e7d6091
                  x-parser-schema-id: <anonymous-schema-5>
                - type: object
                  title: TTSRequestVoiceObject
                  description: >-
                    Voice object. `id` is required; other fields may be added in
                    future API versions.
                  required:
                    - id
                  properties:
                    id:
                      type: string
                      description: The ID of the voice.
                      example: a0e99841-438c-4a64-b679-ae501e7d6091
                      x-parser-schema-id: <anonymous-schema-7>
                  additionalProperties: true
                  x-parser-schema-id: <anonymous-schema-6>
              x-parser-schema-id: <anonymous-schema-4>
            output_format:
              type: object
              description: >-
                Audio output format configuration. Use the same value for all
                generation requests made to the same context.
              required:
                - container
                - encoding
                - sample_rate
              properties:
                container:
                  type: string
                  enum:
                    - raw
                  description: Audio container format
                  default: raw
                  x-parser-schema-id: <anonymous-schema-9>
                encoding:
                  type: string
                  enum:
                    - pcm_f32le
                    - pcm_s16le
                    - pcm_mulaw
                    - pcm_alaw
                  description: >-
                    Audio encoding format. See [TTS Output Audio
                    Format](/build-with-cartesia/capability-guides/tts-output-audio-format)
                    if you're unsure what to use.
                  x-parser-schema-id: <anonymous-schema-10>
                sample_rate:
                  type: integer
                  enum:
                    - 8000
                    - 16000
                    - 22050
                    - 24000
                    - 44100
                    - 48000
                  description: Audio sample rate in Hz.
                  x-parser-schema-id: <anonymous-schema-11>
              x-parser-schema-id: <anonymous-schema-8>
            language: &ref_0
              type: string
              description: >-
                The transcript's language or locale. Use a base language code
                such as `en` or a regional locale code such as `en-GB`.
                `language` and `locale` accept the same values. Set one or the
                other, never both; setting both returns an error. The enum lists
                canonical codes; matching is case-insensitive, and underscore
                locale aliases such as `en_GB` are also accepted. See [supported
                codes](/build-with-cartesia/capability-guides/advanced-capabilities#which-locales-are-supported).
              enum:
                - en
                - fr
                - de
                - es
                - pt
                - zh
                - ja
                - hi
                - it
                - ko
                - nl
                - pl
                - ru
                - sv
                - tr
                - tl
                - bg
                - ro
                - ar
                - cs
                - el
                - fi
                - hr
                - ms
                - sk
                - da
                - ta
                - uk
                - hu
                - 'no'
                - vi
                - bn
                - th
                - he
                - ka
                - id
                - te
                - gu
                - kn
                - ml
                - mr
                - pa
                - or
                - ur
                - bg-BG
                - bn-IN
                - cs-CZ
                - da-DK
                - de-DE
                - el-GR
                - en-AU
                - en-CA
                - en-GB
                - en-IE
                - en-IN
                - en-NZ
                - en-SG
                - en-US
                - en-ZA
                - es-ES
                - es-MX
                - es-US
                - fi-FI
                - fr-CA
                - fr-FR
                - gu-IN
                - he-IL
                - hi-IN
                - hr-HR
                - hu-HU
                - id-ID
                - it-IT
                - ja-JP
                - ka-GE
                - kn-IN
                - ko-KR
                - ml-IN
                - mr-IN
                - ms-MY
                - nl-BE
                - nl-NL
                - no-NO
                - or-IN
                - pa-IN
                - pl-PL
                - pt-BR
                - pt-PT
                - ro-RO
                - ru-RU
                - sk-SK
                - sv-SE
                - ta-IN
                - te-IN
                - th-TH
                - tl-PH
                - tr-TR
                - uk-UA
                - ur-IN
                - vi-VN
                - zh-CN
              x-parser-schema-id: TTSLanguageOrLocale
            locale: *ref_0
            accent:
              type: string
              description: >-
                Usually unnecessary: Cartesia picks the closest accent the voice
                supports for the requested `language` or `locale`. Set it only
                to make a [multilingual
                voice](/build-with-cartesia/capability-guides/multilingual-voices)
                sound accented (e.g. speak English with a French accent). Must
                come from the voice's [Get Voice `accents`
                field](/api-reference/voices/get#response-accents). Learn more
                [here](/build-with-cartesia/capability-guides/multilingual-voices#using-a-multilingual-voice).
              x-parser-schema-id: <anonymous-schema-12>
            normalization:
              type: string
              description: >-
                Text normalization. `auto` (initial default) runs the
                locale-aware normalizer, `off` skips it, or pass a language or
                locale code (for example `en` or `en-IN`) to pin the normalizer
                independently of the generation language. If omitted on a later
                request in the same context, the previous value is reused. See
                [Text
                Normalization](/build-with-cartesia/capability-guides/text-normalization).
              x-parser-schema-id: <anonymous-schema-13>
            context_id: &ref_1
              type: string
              description: >
                A unique identifier for the context. You can use any unique
                identifier, like a UUID or human ID.


                See [Contexts](/use-the-api/tts-websocket/contexts) for details.
              x-parser-schema-id: TTSContextID
            continue:
              type: boolean
              description: |
                Whether `transcript` may be followed by more text:
                  - Set to `true` if you will add more `transcript` chunks to this context
                  - Set to `false` on the last `transcript` chunk for this context to minimize latency

                Defaults to `false`

                See [Contexts](/use-the-api/tts-websocket/contexts) for details
              default: false
              x-parser-schema-id: <anonymous-schema-14>
            max_buffer_delay_ms:
              type: integer
              description: >
                The maximum time in milliseconds to buffer text before starting
                generation. Values between [0, 5000]ms are supported. Defaults
                to 3000ms.


                See [Buffering](/use-the-api/tts-websocket/buffering) for
                details
              default: 3000
              x-parser-schema-id: <anonymous-schema-15>
            flush:
              type: boolean
              description: >
                Whether to flush the context


                See [Context
                Flushing](/use-the-api/tts-websocket/context-flushing-and-flush-i-ds)
                for details
              x-parser-schema-id: <anonymous-schema-16>
            add_timestamps:
              type: boolean
              description: |
                Whether to include word-level timestamps for the generated audio
              default: false
              x-parser-schema-id: <anonymous-schema-17>
            add_phoneme_timestamps:
              type: boolean
              description: >
                Whether to include phoneme-level timestamps for the generated
                audio
              default: false
              x-parser-schema-id: <anonymous-schema-18>
            use_normalized_timestamps:
              type: boolean
              description: >-
                Whether to use normalized timestamps (`true`) or original
                timestamps (`false`)
              x-parser-schema-id: <anonymous-schema-19>
            pronunciation_dict_id:
              type: string
              description: >-
                The ID of a pronunciation dictionary to use for the generation

                See [Custom
                Pronunciations](/build-with-cartesia/capability-guides/custom-pronunciations)
                for details
              x-parser-schema-id: <anonymous-schema-20>
            generation_config:
              type: object
              description: >-
                Configure the various attributes of the generated speech

                See [Volume, Speed, and
                Emotion](/build-with-cartesia/capability-guides/volume-speed-emotion)
                for details
              properties:
                volume:
                  type: number
                  description: >-
                    Adjust the volume of the generated speech between 0.5x and
                    2.0x the default volume. Valid values are between [0.5, 2.0]
                    inclusive.
                  minimum: 0.5
                  maximum: 2
                  default: 1
                  x-parser-schema-id: <anonymous-schema-22>
                speed:
                  type: number
                  description: >-
                    Adjust the speed of the generated speech between 0.6x and
                    1.5x the default speed. Valid values are between [0.6, 1.5]
                    inclusive.
                  minimum: 0.6
                  maximum: 1.5
                  default: 1
                  x-parser-schema-id: <anonymous-schema-23>
                emotion:
                  title: Emotion
                  type: string
                  description: >-
                    Optional. If omitted, the model interprets the emotional
                    subtext of the transcript. Must match a valid option
                    exactly.

                    A complete list can be found on the [Volume, Speed, and
                    Emotion](/build-with-cartesia/capability-guides/volume-speed-emotion)
                    page.
                  enum:
                    - neutral
                    - calm
                    - angry
                    - content
                    - sad
                  x-parser-schema-id: <anonymous-schema-24>
              x-parser-schema-id: <anonymous-schema-21>
          x-parser-schema-id: GenerationRequest
        title: Generation Request
        description: Use this to generate speech for a transcript.
        example: |-
          {
            "model_id": "sonic-latest",
            "transcript": "Hello, world! I'm generating audio on Cartesia!",
            "voice": "a0e99841-438c-4a64-b679-ae501e7d6091",
            "language": "en",
            "context_id": "ab977222-f9e0-4563-a1c0-5a934ae8fdd6",
            "output_format": {
              "container": "raw",
              "encoding": "pcm_s16le",
              "sample_rate": 8000
            },
            "add_timestamps": true,
            "continue": false
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: generationRequest
      - &ref_6
        id: cancelRequest
        payload:
          - name: Cancel Context Request
            description: >-
              Use this to cancel a context, so that no more messages are
              generated for that context.
            type: object
            properties:
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
              - name: cancel
                type: boolean
                description: >-
                  Whether to cancel the context, so that no more messages are
                  generated for that context.
                enumValues:
                  - true
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - context_id
            - cancel
          properties:
            context_id: *ref_1
            cancel:
              type: boolean
              enum:
                - true
              description: >-
                Whether to cancel the context, so that no more messages are
                generated for that context.
              x-parser-schema-id: <anonymous-schema-25>
          x-parser-schema-id: CancelRequest
        title: Cancel Context Request
        description: >-
          Use this to cancel a context, so that no more messages are generated
          for that context.
        example: |-
          {
            "context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79",
            "cancel": true
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: cancelRequest
    bindings: []
    extensions: &ref_2
      - id: x-parser-unique-object-id
        value: /tts/websocket
  - &ref_4
    id: receiveTTSAudio
    title: Receive t t s audio
    description: >-
      The server will send you back a stream of messages with the same
      `context_id` as your request. The messages can be of type `chunk`,
      `timestamps`, `phoneme_timestamps``,` `error`, or `done`.
    type: send
    messages:
      - &ref_7
        id: chunkResponse
        payload:
          - name: Audio Chunk Response
            description: Audio data chunk
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - chunk
                required: true
              - name: data
                type: string
                description: Base64-encoded audio data
                required: true
              - name: done
                type: boolean
                description: Whether this is the final chunk for this context
                required: true
              - name: status_code
                type: integer
                description: HTTP-style status code
                required: true
              - name: step_time
                type: number
                description: Server-side processing time for this chunk in milliseconds
                required: true
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
            - done
            - status_code
            - step_time
            - context_id
          properties:
            type:
              type: string
              enum:
                - chunk
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-26>
            data:
              type: string
              description: Base64-encoded audio data
              x-parser-schema-id: <anonymous-schema-27>
            done:
              type: boolean
              description: Whether this is the final chunk for this context
              x-parser-schema-id: <anonymous-schema-28>
            status_code:
              type: integer
              description: HTTP-style status code
              x-parser-schema-id: <anonymous-schema-29>
            step_time:
              type: number
              description: Server-side processing time for this chunk in milliseconds
              x-parser-schema-id: <anonymous-schema-30>
            context_id: *ref_1
          x-parser-schema-id: ChunkResponse
        title: Audio Chunk Response
        description: Audio data chunk
        example: |-
          {
            "type": "chunk",
            "data": "aSDinaTvuI8gbWludGxpZnk=",
            "done": false,
            "status_code": 206,
            "step_time": 123,
            "context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: chunkResponse
      - &ref_8
        id: flushDoneResponse
        payload:
          - name: Flush Done Response
            description: >-
              Acknowledgment that flush command was received. See [Context
              Flushing](/use-the-api/tts-websocket/context-flushing-and-flush-i-ds)
              for details.
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - flush_done
                required: true
              - name: done
                type: boolean
                description: Whether generation is complete
                required: true
              - name: flush_done
                type: boolean
                description: Whether the flush is complete
                required: true
              - name: flush_id
                type: integer
                description: >-
                  An identifier corresponding to the number of flush commands
                  that have been sent for this context. Starts at 1. This can be
                  used to map chunks of audio to certain transcript submissions.
                required: true
              - name: status_code
                type: integer
                description: HTTP-style status code
                required: true
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - done
            - flush_done
            - flush_id
            - status_code
            - context_id
          properties:
            type:
              type: string
              enum:
                - flush_done
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-31>
            done:
              type: boolean
              description: Whether generation is complete
              x-parser-schema-id: <anonymous-schema-32>
            flush_done:
              type: boolean
              description: Whether the flush is complete
              x-parser-schema-id: <anonymous-schema-33>
            flush_id:
              type: integer
              description: >-
                An identifier corresponding to the number of flush commands that
                have been sent for this context. Starts at 1. This can be used
                to map chunks of audio to certain transcript submissions.
              x-parser-schema-id: <anonymous-schema-34>
            status_code:
              type: integer
              description: HTTP-style status code
              x-parser-schema-id: <anonymous-schema-35>
            context_id: *ref_1
          x-parser-schema-id: FlushDoneResponse
        title: Flush Done Response
        description: >-
          Acknowledgment that flush command was received. See [Context
          Flushing](/use-the-api/tts-websocket/context-flushing-and-flush-i-ds)
          for details.
        example: |-
          {
            "type": "flush_done",
            "done": false,
            "flush_done": true,
            "flush_id": 1,
            "status_code": 206,
            "context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: flushDoneResponse
      - &ref_9
        id: doneResponse
        payload:
          - name: Done Response
            description: Generation completion signal
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - done
                required: true
              - name: done
                type: boolean
                description: Whether generation is complete
                required: true
              - name: status_code
                type: integer
                description: HTTP-style status code
                required: true
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - done
            - status_code
            - context_id
          properties:
            type:
              type: string
              enum:
                - done
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-36>
            done:
              type: boolean
              description: Whether generation is complete
              x-parser-schema-id: <anonymous-schema-37>
            status_code:
              type: integer
              description: HTTP-style status code
              x-parser-schema-id: <anonymous-schema-38>
            context_id: *ref_1
          x-parser-schema-id: DoneResponse
        title: Done Response
        description: Generation completion signal
        example: |-
          {
            "type": "done",
            "done": true,
            "status_code": 206,
            "context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: doneResponse
      - &ref_10
        id: timestampsResponse
        payload:
          - name: Word Timestamps Response
            description: Word-level timing information
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - timestamps
                required: true
              - name: done
                type: boolean
                description: Whether generation is complete
                required: true
              - name: status_code
                type: integer
                description: HTTP-style status code
                required: true
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
              - name: word_timestamps
                type: object
                description: Word-level timing information
                required: false
                properties:
                  - name: words
                    type: array
                    description: List of words in order
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: start
                    type: array
                    description: Start times in seconds for each word
                    required: false
                    properties:
                      - name: item
                        type: number
                        required: false
                  - name: end
                    type: array
                    description: End times in seconds for each word
                    required: false
                    properties:
                      - name: item
                        type: number
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - done
            - status_code
            - context_id
          properties:
            type:
              type: string
              enum:
                - timestamps
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-39>
            done:
              type: boolean
              description: Whether generation is complete
              x-parser-schema-id: <anonymous-schema-40>
            status_code:
              type: integer
              description: HTTP-style status code
              x-parser-schema-id: <anonymous-schema-41>
            context_id: *ref_1
            word_timestamps:
              type: object
              description: Word-level timing information
              properties:
                words:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-44>
                  description: List of words in order
                  x-parser-schema-id: <anonymous-schema-43>
                start:
                  type: array
                  items:
                    type: number
                    x-parser-schema-id: <anonymous-schema-46>
                  description: Start times in seconds for each word
                  x-parser-schema-id: <anonymous-schema-45>
                end:
                  type: array
                  items:
                    type: number
                    x-parser-schema-id: <anonymous-schema-48>
                  description: End times in seconds for each word
                  x-parser-schema-id: <anonymous-schema-47>
              x-parser-schema-id: <anonymous-schema-42>
          x-parser-schema-id: TimestampsResponse
        title: Word Timestamps Response
        description: Word-level timing information
        example: |-
          {
            "type": "timestamps",
            "done": false,
            "status_code": 206,
            "context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
            "word_timestamps": {
              "words": [
                "Hello",
                "world"
              ],
              "start": [
                0,
                0.5
              ],
              "end": [
                0.4,
                0.9
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: timestampsResponse
      - &ref_11
        id: phonemeTimestampsResponse
        payload:
          - name: Phoneme Timestamps Response
            description: Phoneme-level timing information
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - phoneme_timestamps
                required: true
              - name: done
                type: boolean
                description: Whether generation is complete
                required: true
              - name: status_code
                type: integer
                description: HTTP-style status code
                required: true
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: true
              - name: phoneme_timestamps
                type: object
                description: Phoneme-level timing information
                required: false
                properties:
                  - name: phonemes
                    type: array
                    description: List of phonemes in order
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: start
                    type: array
                    description: Start times in seconds for each phoneme
                    required: false
                    properties:
                      - name: item
                        type: number
                        required: false
                  - name: end
                    type: array
                    description: End times in seconds for each phoneme
                    required: false
                    properties:
                      - name: item
                        type: number
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - done
            - status_code
            - context_id
          properties:
            type:
              type: string
              enum:
                - phoneme_timestamps
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-49>
            done:
              type: boolean
              description: Whether generation is complete
              x-parser-schema-id: <anonymous-schema-50>
            status_code:
              type: integer
              description: HTTP-style status code
              x-parser-schema-id: <anonymous-schema-51>
            context_id: *ref_1
            phoneme_timestamps:
              type: object
              description: Phoneme-level timing information
              properties:
                phonemes:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-54>
                  description: List of phonemes in order
                  x-parser-schema-id: <anonymous-schema-53>
                start:
                  type: array
                  items:
                    type: number
                    x-parser-schema-id: <anonymous-schema-56>
                  description: Start times in seconds for each phoneme
                  x-parser-schema-id: <anonymous-schema-55>
                end:
                  type: array
                  items:
                    type: number
                    x-parser-schema-id: <anonymous-schema-58>
                  description: End times in seconds for each phoneme
                  x-parser-schema-id: <anonymous-schema-57>
              x-parser-schema-id: <anonymous-schema-52>
          x-parser-schema-id: PhonemeTimestampsResponse
        title: Phoneme Timestamps Response
        description: Phoneme-level timing information
        example: |-
          {
            "type": "phoneme_timestamps",
            "done": false,
            "status_code": 206,
            "context_id": "872ec12d-bc63-4e1e-a241-4f58c879d105",
            "phoneme_timestamps": {
              "phonemes": [
                "h",
                "ə",
                "l",
                "oʊ"
              ],
              "start": [
                0.093,
                0.174,
                0.255,
                0.337
              ],
              "end": [
                0.174,
                0.255,
                0.337,
                0.418
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: phonemeTimestampsResponse
      - &ref_12
        id: ttsErrorResponse
        payload:
          - name: Error Response
            description: Error information for TTS WebSocket connections.
            type: object
            properties:
              - name: type
                type: string
                description: Response type identifier
                enumValues:
                  - error
                required: true
              - name: done
                type: boolean
                description: Whether generation is complete
                required: false
              - name: error_code
                type: string
                description: Machine-readable error code.
                required: false
              - name: status_code
                type: number
                description: An HTTP response status code.
                required: true
              - name: title
                type: string
                description: Human-readable error title.
                required: true
              - name: message
                type: string
                description: Human-readable error message.
                required: true
              - name: doc_url
                type: string
                description: URL to relevant documentation
                required: false
              - name: request_id
                type: string
                description: Unique identifier for this websocket connection
                required: false
              - name: context_id
                type: string
                description: >
                  A unique identifier for the context. You can use any unique
                  identifier, like a UUID or human ID.


                  See [Contexts](/use-the-api/tts-websocket/contexts) for
                  details.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - title
            - message
            - status_code
          properties:
            type:
              type: string
              enum:
                - error
              description: Response type identifier
              x-parser-schema-id: <anonymous-schema-59>
            done:
              type: boolean
              description: Whether generation is complete
              x-parser-schema-id: <anonymous-schema-60>
            error_code:
              type: string
              description: Machine-readable error code.
              x-parser-schema-id: <anonymous-schema-61>
            status_code:
              type: number
              format: integer
              description: An HTTP response status code.
              x-parser-schema-id: <anonymous-schema-62>
            title:
              type: string
              description: Human-readable error title.
              x-parser-schema-id: <anonymous-schema-63>
            message:
              type: string
              description: Human-readable error message.
              x-parser-schema-id: <anonymous-schema-64>
            doc_url:
              type: string
              description: URL to relevant documentation
              x-parser-schema-id: <anonymous-schema-65>
            request_id:
              type: string
              description: Unique identifier for this websocket connection
              x-parser-schema-id: <anonymous-schema-66>
            context_id: *ref_1
          x-parser-schema-id: TTSErrorResponse
        title: Error Response
        description: Error information for TTS WebSocket connections.
        example: |-
          {
            "type": "error",
            "done": true,
            "title": "Invalid model",
            "message": "The model is not valid, make sure it is a valid model ID.",
            "error_code": "model_not_found",
            "status_code": 400,
            "doc_url": "https://docs.cartesia.ai/build-with-cartesia/tts-models/latest",
            "request_id": "2ff8af53-4d38-479d-8287-58940f01c701",
            "context_id": "50dc3b5e-5841-4aa1-9f94-60cfb9aead79"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ttsErrorResponse
    bindings: []
    extensions: *ref_2
sendOperations:
  - *ref_3
receiveOperations:
  - *ref_4
sendMessages:
  - *ref_5
  - *ref_6
receiveMessages:
  - *ref_7
  - *ref_8
  - *ref_9
  - *ref_10
  - *ref_11
  - *ref_12
extensions:
  - id: x-parser-unique-object-id
    value: /tts/websocket
securitySchemes:
  - id: apiKey
    name: X-API-Key
    type: httpApiKey
    description: Use an API key when you're calling from a trusted server.
    in: header
    extensions: []
  - id: accessTokenQuery
    name: access_token
    type: httpApiKey
    description: >-
      Use a short-lived access token when calling from a browser or client app.
      [Learn more here](/get-started/authenticate-your-client-applications).
    in: query
    extensions: []

````

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