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

# Chat with knowledge base using conversational context



## OpenAPI

````yaml post /knowledge-base/chat
openapi: 3.0.0
info:
  title: ClearTalk API
  description: The ClearTalk API Documentation
  version: '1.0'
  contact:
    name: Developer Support
    email: devsupport@cleartalk.ai
servers:
  - url: https://api.cleartalk.ai
    description: ClearTalk AI API Server
security: []
tags: []
paths:
  /knowledge-base/chat:
    post:
      tags:
        - Knowledge Base
      summary: Chat with knowledge base using conversational context
      operationId: KnowledgeBaseController_chatWithKnowledgeBase
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatWithKnowledgeBaseDto'
      responses:
        '200':
          description: Chat response generated successfully
        '400':
          description: Invalid chat data or knowledge base ID
        '404':
          description: Knowledge base not found
      security:
        - apiKey: []
components:
  schemas:
    ChatWithKnowledgeBaseDto:
      type: object
      properties:
        messages:
          description: Array of chat messages for conversational context
          example:
            - role: user
              content: What is your refund policy?
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        knowledge_base_id:
          type: string
          description: The ID of the knowledge base to query against
          example: kb_01H8X9QK5R2N7P3M6Z8N4Y1V7V
        type:
          type: string
          description: Type of query
          example: web
          default: web
      required:
        - messages
        - knowledge_base_id
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          description: Role of the message sender
          example: user
          enum:
            - user
            - assistant
            - system
        content:
          type: string
          description: Content of the message
          example: What is your refund policy?
      required:
        - role
        - content
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API Key for authentication

````