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

# Connection

> Bidirectional voice agent session. Connect with `?token={jwt}` where the JWT is obtained from `POST /v1/session-token`.



## AsyncAPI

````yaml asyncapi.json connection
id: connection
title: Voice session
description: >-
  Bidirectional voice agent session. Connect with `?token={jwt}` where the JWT
  is obtained from `POST /v1/session-token`.
servers:
  - id: production
    protocol: wss
    host: api.vatel.ai
    bindings: []
    variables: []
address: /v1/connection
parameters: []
bindings: []
operations:
  - &ref_1
    id: voiceSessionSendToServer
    title: 'Voice session: send to server'
    description: Client messages for `/v1/connection`
    type: receive
    messages:
      - &ref_3
        id: InputAudio
        contentType: application/json
        payload:
          - name: Input audio
            description: Client sends captured audio to the server (base64).
            type: object
            properties:
              - name: type
                type: string
                description: input_audio
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: audio
                    type: string
                    description: Base64-encoded audio in PCM 16 24000Hz mono
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: input_audio
              x-parser-schema-id: <anonymous-schema-51>
            data:
              type: object
              required:
                - audio
              properties:
                audio:
                  type: string
                  description: Base64-encoded audio in PCM 16 24000Hz mono
                  x-parser-schema-id: <anonymous-schema-53>
              x-parser-schema-id: <anonymous-schema-52>
          x-parser-schema-id: <anonymous-schema-50>
        title: Input audio
        description: Client sends captured audio to the server (base64).
        example: |-
          {
            "type": "<string>",
            "data": {
              "audio": "<string>"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: InputAudio
      - &ref_4
        id: ToolCallOutput
        contentType: application/json
        payload:
          - name: Tool call output
            description: Client sends the result of a tool call requested by the server.
            type: object
            properties:
              - name: type
                type: string
                description: tool_call_output
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: toolCallId
                    type: string
                    required: true
                  - name: output
                    type: string
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: tool_call_output
              x-parser-schema-id: <anonymous-schema-55>
            data:
              type: object
              required:
                - toolCallId
                - output
              properties:
                toolCallId:
                  type: string
                  x-parser-schema-id: <anonymous-schema-57>
                output:
                  type: string
                  x-parser-schema-id: <anonymous-schema-58>
              x-parser-schema-id: <anonymous-schema-56>
          x-parser-schema-id: <anonymous-schema-54>
        title: Tool call output
        description: Client sends the result of a tool call requested by the server.
        example: |-
          {
            "type": "<string>",
            "data": {
              "toolCallId": "<string>",
              "output": "<string>"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ToolCallOutput
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: connection
  - &ref_2
    id: voiceSessionReceiveFromServer
    title: 'Voice session: receive from server'
    description: Server messages for `/v1/connection`
    type: send
    messages:
      - &ref_5
        id: ServerMessage
        contentType: application/json
        payload:
          - name: Server message
            description: >-
              Discriminated by type; payload in data. One of: session_started,
              response_audio, response_text, input_audio_transcript,
              speech_started, speech_stopped, session_ended, interruption,
              tool_call.
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - session_started
                  - response_audio
                  - response_text
                  - input_audio_transcript
                  - speech_started
                  - speech_stopped
                  - session_ended
                  - interruption
                  - tool_call
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - session_started
                - response_audio
                - response_text
                - input_audio_transcript
                - speech_started
                - speech_stopped
                - session_ended
                - interruption
                - tool_call
              x-parser-schema-id: <anonymous-schema-2>
            data:
              x-parser-schema-id: <anonymous-schema-3>
          x-parser-schema-id: <anonymous-schema-1>
        title: Server message
        description: >-
          Discriminated by type; payload in data. One of: session_started,
          response_audio, response_text, input_audio_transcript, speech_started,
          speech_stopped, session_ended, interruption, tool_call.
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ServerMessage
      - &ref_6
        id: SessionStarted
        contentType: application/json
        payload:
          - name: Session started
            description: Sent when the call session has started.
            type: object
            properties:
              - name: type
                type: string
                description: session_started
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: id
                    type: string
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: session_started
              x-parser-schema-id: <anonymous-schema-5>
            data:
              type: object
              required:
                - id
              properties:
                id:
                  type: string
                  x-parser-schema-id: <anonymous-schema-7>
              x-parser-schema-id: <anonymous-schema-6>
          x-parser-schema-id: <anonymous-schema-4>
        title: Session started
        description: Sent when the call session has started.
        example: |-
          {
            "type": "<string>",
            "data": {
              "id": "<string>"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: SessionStarted
      - &ref_7
        id: ResponseAudio
        contentType: application/json
        payload:
          - name: Response audio
            description: Streamed TTS audio chunk for the current turn.
            type: object
            properties:
              - name: type
                type: string
                description: response_audio
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: turn_id
                    type: string
                    description: Turn or playback context id for this audio stream.
                    required: true
                  - name: audio
                    type: string
                    description: Base64-encoded PCM16 audio.
                    required: true
                  - name: is_final
                    type: boolean
                    description: >-
                      True when this is the last chunk for this utterance or
                      segment.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: response_audio
              x-parser-schema-id: <anonymous-schema-9>
            data:
              type: object
              required:
                - turn_id
                - audio
                - is_final
              properties:
                turn_id:
                  type: string
                  description: Turn or playback context id for this audio stream.
                  x-parser-schema-id: <anonymous-schema-11>
                audio:
                  type: string
                  description: Base64-encoded PCM16 audio.
                  x-parser-schema-id: <anonymous-schema-12>
                is_final:
                  type: boolean
                  description: >-
                    True when this is the last chunk for this utterance or
                    segment.
                  x-parser-schema-id: <anonymous-schema-13>
              x-parser-schema-id: <anonymous-schema-10>
          x-parser-schema-id: <anonymous-schema-8>
        title: Response audio
        description: Streamed TTS audio chunk for the current turn.
        example: |-
          {
            "type": "<string>",
            "data": {
              "turn_id": "<string>",
              "audio": "<string>",
              "is_final": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ResponseAudio
      - &ref_8
        id: ResponseText
        contentType: application/json
        payload:
          - name: Response text
            description: >-
              Agent text for the current turn; may repeat or refine while
              is_final is false.
            type: object
            properties:
              - name: type
                type: string
                description: response_text
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: turn_id
                    type: string
                    description: Turn id associated with this assistant message.
                    required: true
                  - name: text
                    type: string
                    description: >-
                      Assistant text (may repeat or refine while is_final is
                      false).
                    required: true
                  - name: is_final
                    type: boolean
                    description: True when this text is committed for the turn.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: response_text
              x-parser-schema-id: <anonymous-schema-15>
            data:
              type: object
              required:
                - turn_id
                - text
                - is_final
              properties:
                turn_id:
                  type: string
                  description: Turn id associated with this assistant message.
                  x-parser-schema-id: <anonymous-schema-17>
                text:
                  type: string
                  description: >-
                    Assistant text (may repeat or refine while is_final is
                    false).
                  x-parser-schema-id: <anonymous-schema-18>
                is_final:
                  type: boolean
                  description: True when this text is committed for the turn.
                  x-parser-schema-id: <anonymous-schema-19>
              x-parser-schema-id: <anonymous-schema-16>
          x-parser-schema-id: <anonymous-schema-14>
        title: Response text
        description: >-
          Agent text for the current turn; may repeat or refine while is_final
          is false.
        example: |-
          {
            "type": "<string>",
            "data": {
              "turn_id": "<string>",
              "text": "<string>",
              "is_final": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ResponseText
      - &ref_9
        id: InputAudioTranscript
        contentType: application/json
        payload:
          - name: Input audio transcript
            description: >-
              User speech transcript from STT; false is_final for interim
              hypotheses.
            type: object
            properties:
              - name: type
                type: string
                description: input_audio_transcript
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: transcript
                    type: string
                    description: Recognized user speech.
                    required: true
                  - name: turn_id
                    type: string
                    description: Turn id when provided.
                    required: false
                  - name: is_final
                    type: boolean
                    description: False for interim hypotheses; true for final transcript.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: input_audio_transcript
              x-parser-schema-id: <anonymous-schema-21>
            data:
              type: object
              required:
                - transcript
                - is_final
              properties:
                transcript:
                  type: string
                  description: Recognized user speech.
                  x-parser-schema-id: <anonymous-schema-23>
                turn_id:
                  type: string
                  description: Turn id when provided.
                  x-parser-schema-id: <anonymous-schema-24>
                is_final:
                  type: boolean
                  description: False for interim hypotheses; true for final transcript.
                  x-parser-schema-id: <anonymous-schema-25>
              x-parser-schema-id: <anonymous-schema-22>
          x-parser-schema-id: <anonymous-schema-20>
        title: Input audio transcript
        description: >-
          User speech transcript from STT; false is_final for interim
          hypotheses.
        example: |-
          {
            "type": "<string>",
            "data": {
              "transcript": "<string>",
              "turn_id": "<string>",
              "is_final": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: InputAudioTranscript
      - &ref_10
        id: SpeechStarted
        contentType: application/json
        payload:
          - name: Speech started
            description: Sent when user speech (VAD) has started.
            type: object
            properties:
              - name: type
                type: string
                description: speech_started
                required: true
              - name: data
                type: object
                required: false
                properties:
                  - name: emulated
                    type: boolean
                    description: >-
                      When true, speech activity was driven by transcript (e.g.
                      STT text) rather than raw audio, which turned VAD on as if
                      the user had started speaking.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: speech_started
              x-parser-schema-id: <anonymous-schema-27>
            data:
              type: object
              required:
                - emulated
              properties:
                emulated:
                  type: boolean
                  description: >-
                    When true, speech activity was driven by transcript (e.g.
                    STT text) rather than raw audio, which turned VAD on as if
                    the user had started speaking.
                  x-parser-schema-id: <anonymous-schema-29>
              x-parser-schema-id: <anonymous-schema-28>
          x-parser-schema-id: <anonymous-schema-26>
        title: Speech started
        description: Sent when user speech (VAD) has started.
        example: |-
          {
            "type": "<string>",
            "data": {
              "emulated": true
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: SpeechStarted
      - &ref_11
        id: SpeechStopped
        contentType: application/json
        payload:
          - name: Speech stopped
            description: Sent when user speech (VAD) has stopped.
            type: object
            properties:
              - name: type
                type: string
                description: speech_stopped
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: speech_stopped
              x-parser-schema-id: <anonymous-schema-31>
          x-parser-schema-id: <anonymous-schema-30>
        title: Speech stopped
        description: Sent when user speech (VAD) has stopped.
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: SpeechStopped
      - &ref_12
        id: SessionEnded
        contentType: application/json
        payload:
          - name: Session ended
            description: Sent when the call session has ended.
            type: object
            properties:
              - name: type
                type: string
                description: session_ended
                required: true
              - name: data
                type: object
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: session_ended
              x-parser-schema-id: <anonymous-schema-33>
            data:
              type: object
              x-parser-schema-id: <anonymous-schema-34>
          x-parser-schema-id: <anonymous-schema-32>
        title: Session ended
        description: Sent when the call session has ended.
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: SessionEnded
      - &ref_13
        id: Interruption
        contentType: application/json
        payload:
          - name: Interruption
            description: Sent when user has interrupted the agent.
            type: object
            properties:
              - name: type
                type: string
                description: interruption
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: interruption
              x-parser-schema-id: <anonymous-schema-36>
          x-parser-schema-id: <anonymous-schema-35>
        title: Interruption
        description: Sent when user has interrupted the agent.
        example: |-
          {
            "type": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: Interruption
      - &ref_14
        id: ToolCall
        contentType: application/json
        payload:
          - name: Tool call
            description: >-
              Server requests the client to execute a tool and respond with
              tool_call_output.
            type: object
            properties:
              - name: type
                type: string
                description: tool_call
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: toolCallId
                    type: string
                    description: >-
                      Opaque id for this invocation; echo it in tool_call_output
                      so the server can correlate the result.
                    required: true
                  - name: toolName
                    type: string
                    description: Name of the tool to run on the client.
                    required: true
                  - name: arguments
                    type: array
                    description: >-
                      Structured parameters for this tool call, each with schema
                      metadata and the value supplied for this turn.
                    required: true
                    properties:
                      - name: name
                        type: string
                        description: Parameter name as defined by the tool schema.
                        required: false
                      - name: type
                        type: string
                        description: Static, dynamic or resolved type of the parameter.
                        required: false
                      - name: dataType
                        type: string
                        description: Data type of the value.
                        required: false
                      - name: description
                        type: string
                        description: >-
                          Human-readable explanation of what this parameter
                          means.
                        required: false
                      - name: description
                        type: string
                        description: >-
                          Concrete value for this invocation; type depends on
                          dataType and tool contract.
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - data
          properties:
            type:
              type: string
              const: tool_call
              x-parser-schema-id: <anonymous-schema-38>
            data:
              type: object
              required:
                - toolCallId
                - toolName
                - arguments
              properties:
                toolCallId:
                  type: string
                  description: >-
                    Opaque id for this invocation; echo it in tool_call_output
                    so the server can correlate the result.
                  x-parser-schema-id: <anonymous-schema-40>
                toolName:
                  type: string
                  description: Name of the tool to run on the client.
                  x-parser-schema-id: <anonymous-schema-41>
                arguments:
                  type: array
                  description: >-
                    Structured parameters for this tool call, each with schema
                    metadata and the value supplied for this turn.
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Parameter name as defined by the tool schema.
                        x-parser-schema-id: <anonymous-schema-44>
                      type:
                        type: string
                        description: Static, dynamic or resolved type of the parameter.
                        x-parser-schema-id: <anonymous-schema-45>
                      dataType:
                        type: string
                        description: Data type of the value.
                        x-parser-schema-id: <anonymous-schema-46>
                      description:
                        type: string
                        description: >-
                          Human-readable explanation of what this parameter
                          means.
                        x-parser-schema-id: <anonymous-schema-47>
                      required:
                        type: boolean
                        description: >-
                          Whether the tool schema marks this parameter as
                          required.
                        x-parser-schema-id: <anonymous-schema-48>
                      value:
                        description: >-
                          Concrete value for this invocation; type depends on
                          dataType and tool contract.
                        x-parser-schema-id: <anonymous-schema-49>
                    x-parser-schema-id: <anonymous-schema-43>
                  x-parser-schema-id: <anonymous-schema-42>
              x-parser-schema-id: <anonymous-schema-39>
          x-parser-schema-id: <anonymous-schema-37>
        title: Tool call
        description: >-
          Server requests the client to execute a tool and respond with
          tool_call_output.
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: ToolCall
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
  - *ref_4
receiveMessages:
  - *ref_5
  - *ref_6
  - *ref_7
  - *ref_8
  - *ref_9
  - *ref_10
  - *ref_11
  - *ref_12
  - *ref_13
  - *ref_14
extensions:
  - id: x-parser-unique-object-id
    value: connection
securitySchemes: []

````