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

# Chat

> Main entry point for all user chat messages.

Implements the two-hop routing pattern: looks up the organization's main
agent and streams the response. In v1, this forwards directly to the main
agent's runner streaming. Future versions will add non-streaming routing
hop where the main agent selects a target instance before streaming.

The tenant SurrealDB namespace keyed by the authenticated caller's
organization is the isolation boundary for both the agent type and
the agent resource lookups the runner resolution traverses.

Returns:
    SSE stream of the agent's response.

Raises:
    NotFoundError: If no main router agent seeded for the organization.



## OpenAPI

````yaml https://api.pragmatiks.io/openapi.json post /agents/chat
openapi: 3.1.0
info:
  title: Pragma API
  version: 0.1.0
servers: []
security: []
paths:
  /agents/chat:
    post:
      tags:
        - conversation-routing
      summary: Chat
      description: >-
        Main entry point for all user chat messages.


        Implements the two-hop routing pattern: looks up the organization's main

        agent and streams the response. In v1, this forwards directly to the
        main

        agent's runner streaming. Future versions will add non-streaming routing

        hop where the main agent selects a target instance before streaming.


        The tenant SurrealDB namespace keyed by the authenticated caller's

        organization is the isolation boundary for both the agent type and

        the agent resource lookups the runner resolution traverses.


        Returns:
            SSE stream of the agent's response.

        Raises:
            NotFoundError: If no main router agent seeded for the organization.
      operationId: conversation-routing-chat
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatMessage'
        required: true
      responses:
        '200':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ChatMessage:
      properties:
        message:
          type: string
          title: Message
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
      type: object
      required:
        - message
      title: ChatMessage
      description: |-
        Request body for the main chat entry point.

        Attributes:
            message: The user message to send.
            session_id: Session ID for conversation continuity. New session if None.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````