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

# Chat With Agent

> Send a text message to an agent and get a response.

This endpoint allows REST API-based interactions with agents,
useful for:
- Web chat interfaces
- API integrations
- Testing agent behavior
- Non-voice applications

Example:
```json
{
  "query": "What is your refund policy?",
  "conversation_id": "conv-123",  // Optional, for follow-up
  "top_k": 5
}
```

Response:
```json
{
  "response": "Our refund policy allows...",
  "payload": null,
  "selected_tool": null,
  "conversation_id": "conv-123",
  "trace_id": "trace-abc",
  "execution_time_ms": 850,
  "versions": {"kb_v": "1.0", "policy_v": "1.0", "tools_v": "1.0"}
}
```



## OpenAPI

````yaml https://api.mrassistant.ai/openapi.json post /agents/{agent_id}/chat
openapi: 3.1.0
info:
  title: Backend - Multilingual Voice Agent System
  description: FastAPI backend for multilingual voice agents with tool use
  version: 1.0.0
servers: []
security: []
paths:
  /agents/{agent_id}/chat:
    post:
      tags:
        - agent-chat
      summary: Chat With Agent
      description: |-
        Send a text message to an agent and get a response.

        This endpoint allows REST API-based interactions with agents,
        useful for:
        - Web chat interfaces
        - API integrations
        - Testing agent behavior
        - Non-voice applications

        Example:
        ```json
        {
          "query": "What is your refund policy?",
          "conversation_id": "conv-123",  // Optional, for follow-up
          "top_k": 5
        }
        ```

        Response:
        ```json
        {
          "response": "Our refund policy allows...",
          "payload": null,
          "selected_tool": null,
          "conversation_id": "conv-123",
          "trace_id": "trace-abc",
          "execution_time_ms": 850,
          "versions": {"kb_v": "1.0", "policy_v": "1.0", "tools_v": "1.0"}
        }
        ```
      operationId: chat_with_agent_agents__agent_id__chat_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ChatRequest:
      properties:
        query:
          type: string
          maxLength: 2000
          minLength: 1
          title: Query
          description: User's message/query
        conversation_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Conversation Id
          description: Existing conversation ID to continue
        context_overrides:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Context Overrides
          description: Additional context for this query
        top_k:
          type: integer
          maximum: 20
          minimum: 1
          title: Top K
          description: Number of knowledge chunks to retrieve
          default: 5
      type: object
      required:
        - query
      title: ChatRequest
      description: Request to chat with an agent via text.
    ChatResponse:
      properties:
        response:
          type: string
          title: Response
          description: Agent's text response
        payload:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Payload
          description: Tool output payload if applicable
        selected_tool:
          anyOf:
            - type: string
            - type: 'null'
          title: Selected Tool
          description: Tool that was executed
        conversation_id:
          type: string
          title: Conversation Id
          description: Conversation ID for follow-up messages
        trace_id:
          type: string
          title: Trace Id
          description: Trace ID for debugging
        execution_time_ms:
          type: integer
          title: Execution Time Ms
          description: Execution time in milliseconds
        outcome_label:
          anyOf:
            - type: string
            - type: 'null'
          title: Outcome Label
          description: Outcome classification
        versions:
          additionalProperties:
            type: string
          type: object
          title: Versions
          description: Version information (kb, policy, tools)
      type: object
      required:
        - response
        - conversation_id
        - trace_id
        - execution_time_ms
        - versions
      title: ChatResponse
      description: Response from agent chat.
    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
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````