> This page is for APIs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# ai.completion

GET /

Receive ai.completion events

Reference: https://signalwire.com/docs/apis/relay/client/fabric/ai-completion

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: ai.completion
  version: subpackage_aiCompletion.ai.completion
  description: Receive ai.completion events
channels:
  /:
    description: Receive ai.completion events
    publish:
      operationId: subpackage_aiCompletion.ai.completion-publish
      summary: ai.completion
      message:
        name: onAiCompletionFabricAiCompletionEvent
        title: ai.completion
        payload:
          $ref: '#/components/schemas/ai.completion_fabricAiCompletionEvent'
servers:
  production:
    url: wss://relay.signalwire.com/
    protocol: wss
    x-default: true
components:
  schemas:
    ChannelsAiCompletionMessagesFabricAiCompletionEventJsonrpc:
      type: string
      enum:
        - '2.0'
      description: JSON-RPC version. Always `2.0`.
      title: ChannelsAiCompletionMessagesFabricAiCompletionEventJsonrpc
    ChannelsAiCompletionMessagesFabricAiCompletionEventMethod:
      type: string
      enum:
        - signalwire.event
      description: Always `signalwire.event`.
      title: ChannelsAiCompletionMessagesFabricAiCompletionEventMethod
    ChannelsAiCompletionMessagesFabricAiCompletionEventParamsEventType:
      type: string
      enum:
        - ai.completion
      description: The event type — identifies which event this is.
      title: ChannelsAiCompletionMessagesFabricAiCompletionEventParamsEventType
    FabricFabricAiCompletionParamsType:
      type: string
      enum:
        - normal
        - barged
      description: >-
        Whether the turn completed normally or was cut short by a barge-in:
        `barged` when the caller interrupted the assistant, otherwise `normal`.
        Always `normal` on `calling.amazon_bedrock` sessions.
      title: FabricFabricAiCompletionParamsType
    Fabric.FabricAiCompletionParams:
      type: object
      properties:
        call_id:
          type: string
          description: >-
            Unique identifier of the call this event is about. Always present on
            Fabric events.
        node_id:
          type: string
          description: The node the call leg lives on.
        room_session_id:
          type: string
          description: >-
            The room session this call leg belongs to. In a 1:1 call this equals
            the `call_id`.
        segment_id:
          type: string
          description: >-
            Identifier of the call segment this event belongs to, for
            correlating events within the same segment.
        tag:
          type: string
          description: >-
            The `tag` the leg was dialed with, when a server-side application
            set one on the dial. Absent otherwise.
        text:
          type: string
          description: >-
            The assistant's completed utterance for the turn. Redacted when the
            app has `redact_prompt` set. Always an empty string on
            `calling.amazon_bedrock` sessions.
        type:
          $ref: '#/components/schemas/FabricFabricAiCompletionParamsType'
          description: >-
            Whether the turn completed normally or was cut short by a barge-in:
            `barged` when the caller interrupted the assistant, otherwise
            `normal`. Always `normal` on `calling.amazon_bedrock` sessions.
      required:
        - call_id
        - node_id
        - room_session_id
        - text
        - type
      title: Fabric.FabricAiCompletionParams
    ChannelsAiCompletionMessagesFabricAiCompletionEventParams:
      type: object
      properties:
        event_type:
          $ref: >-
            #/components/schemas/ChannelsAiCompletionMessagesFabricAiCompletionEventParamsEventType
          description: The event type — identifies which event this is.
        event_channel:
          type: string
          description: >-
            The channel the event was delivered on — for Calling events, the
            `protocol`

            string your connection received from `signalwire.connect`.
        timestamp:
          type: number
          format: double
          description: >-
            When the event was emitted, as a Unix timestamp in seconds. Always
            present.
        project_id:
          type: string
          description: >-
            Your project ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        space_id:
          type: string
          description: >-
            Your space ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        params:
          $ref: '#/components/schemas/Fabric.FabricAiCompletionParams'
          description: The event-specific payload.
      required:
        - event_type
        - event_channel
        - timestamp
        - params
      description: The event envelope.
      title: ChannelsAiCompletionMessagesFabricAiCompletionEventParams
    ai.completion_fabricAiCompletionEvent:
      type: object
      properties:
        jsonrpc:
          $ref: >-
            #/components/schemas/ChannelsAiCompletionMessagesFabricAiCompletionEventJsonrpc
          description: JSON-RPC version. Always `2.0`.
        id:
          type: string
          description: >-
            Event id — a unique UUID generated for each event. Events are
            notifications: you do not reply to them.
        method:
          $ref: >-
            #/components/schemas/ChannelsAiCompletionMessagesFabricAiCompletionEventMethod
          description: Always `signalwire.event`.
        params:
          $ref: >-
            #/components/schemas/ChannelsAiCompletionMessagesFabricAiCompletionEventParams
          description: The event envelope.
      required:
        - jsonrpc
        - id
        - method
        - params
      description: >-
        Fires on a Call Fabric call leg when the agent completes a response
        turn, with the response `text` and whether it was `barged`. Same fields
        as the Calling API's `calling.ai.completion` event. SWML or a
        server-side application starts the AI agent on the leg; there is no
        client request that starts it.
      title: ai.completion_fabricAiCompletionEvent

```