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

# ASR WebSocket

> Streaming speech to text. After the connection opens, the server sends `session.started`. Send audio as binary frames in the declared `audio_format`, as you capture it. The server sends `transcript.delta` events with new text as it is recognized. Send `input.done` after the last frame: the server sends `transcript.done` with the complete transcript and closes with code 1000.
Send `keepalive` while you have no audio, so the session is not closed as idle. A session lasts at most `max_duration_seconds` (from `session.started`); `session.expiring` arrives about a minute before the limit.
Billing is 1.5 credits per second of audio sent, charged periodically during the session and settled when it closes. Each open session uses one speech-to-text concurrency slot until it closes.
Authenticate with the `chariotai-api-key` header, or with the `api_key` query parameter when your client cannot set handshake headers.
Terminal errors send an `error` event whose `code` matches the close code that follows: `1008` for an auth problem, an invalid parameter, a product not on your plan, or the idle timeout; `1011` for a server error or a language, mode, or style that cannot be served right now; `4402` for insufficient credits; `4413` when the session reaches its maximum duration; and `4429` for the concurrency limit. An `error` event without a `code` concerns one message, and the session continues.




## AsyncAPI

````yaml api-reference/asyncapi.yaml asrStream
id: asrStream
title: Speech to text stream
description: >
  Streaming speech to text. After the connection opens, the server sends
  `session.started`. Send audio as binary frames in the declared `audio_format`,
  as you capture it. The server sends `transcript.delta` events with new text as
  it is recognized. Send `input.done` after the last frame: the server sends
  `transcript.done` with the complete transcript and closes with code 1000.

  Send `keepalive` while you have no audio, so the session is not closed as
  idle. A session lasts at most `max_duration_seconds` (from `session.started`);
  `session.expiring` arrives about a minute before the limit.

  Billing is 1.5 credits per second of audio sent, charged periodically during
  the session and settled when it closes. Each open session uses one
  speech-to-text concurrency slot until it closes.

  Authenticate with the `chariotai-api-key` header, or with the `api_key` query
  parameter when your client cannot set handshake headers.

  Terminal errors send an `error` event whose `code` matches the close code that
  follows: `1008` for an auth problem, an invalid parameter, a product not on
  your plan, or the idle timeout; `1011` for a server error or a language, mode,
  or style that cannot be served right now; `4402` for insufficient credits;
  `4413` when the session reaches its maximum duration; and `4429` for the
  concurrency limit. An `error` event without a `code` concerns one message, and
  the session continues.
servers:
  - id: production
    protocol: wss
    host: api.chariot.in
    bindings: []
    variables: []
address: /v1/asr/ws
parameters: []
bindings:
  - protocol: ws
    version: 0.1.0
    value:
      method: GET
      query:
        type: object
        properties:
          audio_format:
            type: string
            enum:
              - pcm_8000
              - pcm_16000
              - pcm_22050
              - pcm_24000
              - pcm_32000
              - pcm_44100
              - pcm_48000
              - ulaw_8000
              - alaw_8000
            default: pcm_16000
            examples: &ref_0
              - pcm_16000
            description: >
              Encoding and sample rate of the audio you send, always mono.
              `pcm_*` is signed 16-bit little-endian PCM at the named rate.
              `ulaw_8000` and `alaw_8000` are G.711 telephony audio at 8 kHz.
              Declare the rate you actually send: audio at another rate is
              transcribed as the wrong speech, without an error.
          language:
            type: string
            enum:
              - en
              - hi
              - bn
              - gu
              - kn
              - ml
              - mr
              - or
              - pa
              - sa
              - ta
              - te
              - none
            examples: &ref_1
              - en
            description: >
              Language hint for the session. It does not translate. Omit it, or
              pass `none`, for automatic language detection.
          mode:
            type: string
            enum:
              - balanced
              - high_accuracy
            default: balanced
            examples: &ref_2
              - balanced
            description: >
              `balanced` prioritizes responsiveness, for interactive
              applications. `high_accuracy` allows more context before
              committing text, which increases latency and usually gives more
              accurate transcripts. Both cost the same.
          style:
            type: string
            enum:
              - codemix
              - native
            default: codemix
            examples: &ref_3
              - codemix
            description: >
              How mixed-language speech is written. `codemix` keeps borrowed
              words, usually English, in their own script. `native` writes
              everything in the script of the spoken language.
          model_type:
            type: string
            enum:
              - chariot-1-asr-realtime
            default: chariot-1-asr-realtime
            examples: &ref_4
              - chariot-1-asr-realtime
            description: The speech-to-text model. Default and only value.
          idle_timeout:
            type: number
            default: 60
            exclusiveMinimum: 0
            maximum: 300
            examples: &ref_5
              - 60
            description: >
              Seconds the server waits for your next message, audio or JSON,
              before closing the session as idle with code 1008. Must be greater
              than 0 and at most 300.
          api_key:
            type: string
            description: >
              Your API key. Prefer the `chariotai-api-key` header where your
              client supports it.
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
      - name: query
        type: object
        required: false
        properties:
          - name: audio_format
            type: string
            description: >
              Encoding and sample rate of the audio you send, always mono.
              `pcm_*` is signed 16-bit little-endian PCM at the named rate.
              `ulaw_8000` and `alaw_8000` are G.711 telephony audio at 8 kHz.
              Declare the rate you actually send: audio at another rate is
              transcribed as the wrong speech, without an error.
            enumValues:
              - pcm_8000
              - pcm_16000
              - pcm_22050
              - pcm_24000
              - pcm_32000
              - pcm_44100
              - pcm_48000
              - ulaw_8000
              - alaw_8000
            examples: *ref_0
            required: false
          - name: language
            type: string
            description: >
              Language hint for the session. It does not translate. Omit it, or
              pass `none`, for automatic language detection.
            enumValues:
              - en
              - hi
              - bn
              - gu
              - kn
              - ml
              - mr
              - or
              - pa
              - sa
              - ta
              - te
              - none
            examples: *ref_1
            required: false
          - name: mode
            type: string
            description: >
              `balanced` prioritizes responsiveness, for interactive
              applications. `high_accuracy` allows more context before
              committing text, which increases latency and usually gives more
              accurate transcripts. Both cost the same.
            enumValues:
              - balanced
              - high_accuracy
            examples: *ref_2
            required: false
          - name: style
            type: string
            description: >
              How mixed-language speech is written. `codemix` keeps borrowed
              words, usually English, in their own script. `native` writes
              everything in the script of the spoken language.
            enumValues:
              - codemix
              - native
            examples: *ref_3
            required: false
          - name: model_type
            type: string
            description: The speech-to-text model. Default and only value.
            enumValues:
              - chariot-1-asr-realtime
            examples: *ref_4
            required: false
          - name: idle_timeout
            type: number
            description: >
              Seconds the server waits for your next message, audio or JSON,
              before closing the session as idle with code 1008. Must be greater
              than 0 and at most 300.
            examples: *ref_5
            required: false
          - name: api_key
            type: string
            description: >
              Your API key. Prefer the `chariotai-api-key` header where your
              client supports it.
            required: false
operations:
  - &ref_17
    id: sendToChariotAsr
    title: Client to server
    description: Audio and messages you send to Chariot.
    type: receive
    messages:
      - &ref_19
        id: audio
        contentType: application/octet-stream
        payload:
          - type: string
            format: binary
            x-parser-schema-id: <anonymous-schema-86>
            name: Audio
            description: >
              A binary WebSocket frame of raw audio in the declared
              `audio_format`. No file header, JSON, or base64. Any frame size
              works; about 100 ms per frame is a good default.
        headers: []
        jsonPayloadSchema:
          type: string
          format: binary
          x-parser-schema-id: <anonymous-schema-86>
        title: Audio
        description: >
          A binary WebSocket frame of raw audio in the declared `audio_format`.
          No file header, JSON, or base64. Any frame size works; about 100 ms
          per frame is a good default.
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: audio
      - &ref_20
        id: keepalive
        payload:
          - name: Keep alive
            description: >
              Keeps the session open while you have no audio to send. Resets the
              idle timer. No reply.
            type: object
            properties:
              - name: type
                type: string
                description: keepalive
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: keepalive
              x-parser-schema-id: <anonymous-schema-88>
          x-parser-schema-id: <anonymous-schema-87>
        title: Keep alive
        description: >
          Keeps the session open while you have no audio to send. Resets the
          idle timer. No reply.
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: keepalive
      - &ref_21
        id: inputDone
        payload:
          - name: End input
            description: >
              No more audio is coming. The server transcribes the rest, sends
              `transcript.done`, and closes with code 1000. Audio sent
              afterwards is not transcribed.
            type: object
            properties:
              - name: type
                type: string
                description: input.done
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: input.done
              x-parser-schema-id: <anonymous-schema-90>
          x-parser-schema-id: <anonymous-schema-89>
        title: End input
        description: >
          No more audio is coming. The server transcribes the rest, sends
          `transcript.done`, and closes with code 1000. Audio sent afterwards is
          not transcribed.
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: inputDone
    bindings: []
    extensions: &ref_16
      - id: x-parser-unique-object-id
        value: asrStream
  - &ref_18
    id: receiveFromChariotAsr
    title: Server to client
    description: Events Chariot sends back to you.
    type: send
    messages:
      - &ref_22
        id: sessionStarted
        payload:
          - name: Session started
            description: >-
              The session is ready for audio. Sent once, first, with the
              settings in effect.
            type: object
            properties:
              - name: type
                type: string
                description: session.started
                required: false
              - name: session_id
                type: string
                description: >-
                  Unique id for the session. Use it with `GET
                  /v1/asr/sessions/{session_id}`.
                required: false
              - name: model_type
                type: string
                examples: &ref_6
                  - chariot-1-asr-realtime
                required: false
              - name: sample_rate
                type: integer
                description: Sample rate of the declared audio format, in Hz.
                examples: &ref_7
                  - 16000
                required: false
              - name: language
                type: &ref_8
                  - string
                  - 'null'
                description: The language hint, or null for automatic language detection.
                required: false
              - name: mode
                type: string
                enumValues:
                  - balanced
                  - high_accuracy
                required: false
              - name: style
                type: string
                enumValues:
                  - codemix
                  - native
                required: false
              - name: audio_format
                type: string
                examples: &ref_9
                  - pcm_16000
                required: false
              - name: max_duration_seconds
                type: integer
                description: The longest this session can run, in seconds.
                examples: &ref_10
                  - 10800
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: session.started
              x-parser-schema-id: <anonymous-schema-92>
            session_id:
              type: string
              format: uuid
              description: >-
                Unique id for the session. Use it with `GET
                /v1/asr/sessions/{session_id}`.
              x-parser-schema-id: <anonymous-schema-93>
            model_type:
              type: string
              examples: *ref_6
              x-parser-schema-id: <anonymous-schema-94>
            sample_rate:
              type: integer
              description: Sample rate of the declared audio format, in Hz.
              examples: *ref_7
              x-parser-schema-id: <anonymous-schema-95>
            language:
              type: *ref_8
              description: The language hint, or null for automatic language detection.
              x-parser-schema-id: <anonymous-schema-96>
            mode:
              type: string
              enum:
                - balanced
                - high_accuracy
              x-parser-schema-id: <anonymous-schema-97>
            style:
              type: string
              enum:
                - codemix
                - native
              x-parser-schema-id: <anonymous-schema-98>
            audio_format:
              type: string
              examples: *ref_9
              x-parser-schema-id: <anonymous-schema-99>
            max_duration_seconds:
              type: integer
              description: The longest this session can run, in seconds.
              examples: *ref_10
              x-parser-schema-id: <anonymous-schema-100>
          x-parser-schema-id: <anonymous-schema-91>
        title: Session started
        description: >-
          The session is ready for audio. Sent once, first, with the settings in
          effect.
        example: |-
          {
            "type": "<string>",
            "session_id": "<string>",
            "model_type": "<string>",
            "sample_rate": 123,
            "mode": "<string>",
            "style": "<string>",
            "audio_format": "<string>",
            "max_duration_seconds": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: sessionStarted
      - &ref_23
        id: transcriptDelta
        payload:
          - name: Transcript delta
            description: >
              New text, as it is recognized. Append it to the text so far;
              spaces are included. Use `transcript.done` for the final text.
            type: object
            properties:
              - name: type
                type: string
                description: transcript.delta
                required: false
              - name: text
                type: string
                examples: &ref_11
                  - ' the meeting'
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: transcript.delta
              x-parser-schema-id: <anonymous-schema-102>
            text:
              type: string
              examples: *ref_11
              x-parser-schema-id: <anonymous-schema-103>
          x-parser-schema-id: <anonymous-schema-101>
        title: Transcript delta
        description: >
          New text, as it is recognized. Append it to the text so far; spaces
          are included. Use `transcript.done` for the final text.
        example: |-
          {
            "type": "<string>",
            "text": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: transcriptDelta
      - &ref_24
        id: transcriptDone
        payload:
          - name: Transcript done
            description: >
              The complete transcript, sent once after `input.done`. The
              connection then closes with code 1000.
            type: object
            properties:
              - name: type
                type: string
                description: transcript.done
                required: false
              - name: text
                type: string
                examples: &ref_12
                  - Hi, I'd like to move the meeting to Thursday.
                required: false
              - name: audio_seconds
                type: number
                description: Duration of the audio you sent, in seconds.
                examples: &ref_13
                  - 4.82
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: transcript.done
              x-parser-schema-id: <anonymous-schema-105>
            text:
              type: string
              examples: *ref_12
              x-parser-schema-id: <anonymous-schema-106>
            audio_seconds:
              type: number
              description: Duration of the audio you sent, in seconds.
              examples: *ref_13
              x-parser-schema-id: <anonymous-schema-107>
          x-parser-schema-id: <anonymous-schema-104>
        title: Transcript done
        description: >
          The complete transcript, sent once after `input.done`. The connection
          then closes with code 1000.
        example: |-
          {
            "type": "<string>",
            "text": "<string>",
            "audio_seconds": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: transcriptDone
      - &ref_25
        id: sessionExpiring
        payload:
          - name: Session expiring
            description: >
              The session reaches `max_duration_seconds` soon. Sent once, about
              a minute before the limit. At the limit the session closes with
              4413.
            type: object
            properties:
              - name: type
                type: string
                description: session.expiring
                required: false
              - name: seconds_remaining
                type: integer
                examples: &ref_14
                  - 52
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: session.expiring
              x-parser-schema-id: <anonymous-schema-109>
            seconds_remaining:
              type: integer
              examples: *ref_14
              x-parser-schema-id: <anonymous-schema-110>
          x-parser-schema-id: <anonymous-schema-108>
        title: Session expiring
        description: >
          The session reaches `max_duration_seconds` soon. Sent once, about a
          minute before the limit. At the limit the session closes with 4413.
        example: |-
          {
            "type": "<string>",
            "seconds_remaining": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: sessionExpiring
      - &ref_26
        id: errorMessage
        payload:
          - name: Error
            description: >
              An error. With a `code`, it is terminal and the connection closes
              with that code. Without a `code`, it concerns one message (invalid
              JSON or an unknown message type) and the session continues.
            type: object
            properties:
              - name: type
                type: string
                description: error
                required: false
              - name: code
                type: integer
                description: The close code that follows. Absent for nonterminal errors.
                enumValues:
                  - 1008
                  - 1011
                  - 4402
                  - 4413
                  - 4429
                required: false
              - name: message
                type: string
                examples: &ref_15
                  - Insufficient credits
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: error
              x-parser-schema-id: <anonymous-schema-112>
            code:
              type: integer
              enum:
                - 1008
                - 1011
                - 4402
                - 4413
                - 4429
              description: The close code that follows. Absent for nonterminal errors.
              x-parser-schema-id: <anonymous-schema-113>
            message:
              type: string
              examples: *ref_15
              x-parser-schema-id: <anonymous-schema-114>
          x-parser-schema-id: <anonymous-schema-111>
        title: Error
        description: >
          An error. With a `code`, it is terminal and the connection closes with
          that code. Without a `code`, it concerns one message (invalid JSON or
          an unknown message type) and the session continues.
        example: |-
          {
            "type": "<string>",
            "code": 123,
            "message": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: errorMessage
    bindings: []
    extensions: *ref_16
sendOperations:
  - *ref_17
receiveOperations:
  - *ref_18
sendMessages:
  - *ref_19
  - *ref_20
  - *ref_21
receiveMessages:
  - *ref_22
  - *ref_23
  - *ref_24
  - *ref_25
  - *ref_26
extensions:
  - id: x-parser-unique-object-id
    value: asrStream
securitySchemes: []

````

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