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

# Agents Conversation

> This endpoint is used to receive agent chat request from user through API and return the answer.



## OpenAPI

````yaml POST /agents/chat/request
openapi: 3.1.0
info:
  title: Pawa AI APIs
  description: >-
    API endpoints in Pawa Platform to perform CRUD operations on different
    features using Pawa AI, a digital assistant built for Africa for various
    tasks.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.pawa-ai.com/v1
    description: Production Server
security:
  - bearerAuth: []
paths:
  /agents/chat/request:
    post:
      tags:
        - Agent chat request
      summary: Agent chat request
      description: >-
        This endpoint is used to receive agent chat request from user through
        API and return the answer.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentChatRequestDto'
      responses:
        '200':
          description: Agent chat request processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatRequestResponseDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                badRequest:
                  value:
                    success: false
                    message: Invalid input provided
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  value:
                    success: false
                    message: Unauthorized access
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  value:
                    success: false
                    message: You do not have permission to access this resource
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notFound:
                  value:
                    success: false
                    message: Resource does not exist
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                tooManyRequests:
                  value:
                    success: false
                    message: Rate limit exceeded. Please try again later.
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                serverError:
                  value:
                    success: false
                    message: Internal server error
components:
  schemas:
    AgentChatRequestDto:
      type: object
      properties:
        name:
          type: string
          description: The name of the agent
          example: TutorAI
        description:
          type: string
          description: The description about the agent
          example: >-
            TutorAI is an AI agent designed to assist students with their
            studies.
        instruction:
          type: string
          description: What should the agent do
          example: >-
            Teaching students on subjects ranging from form 0ne to form 4.
            Follow questions properly and do not answer any other questions
            apart from what you have been tasked to
        intents:
          type: array
          description: The list of intents, how the model should behave?
          example:
            - Be gentle
            - Be detailed
        model:
          type: string
          description: The name of the model to use.
          default: pawa-v1-blaze-20250318
        message:
          description: Messages to send to the model
          example:
            role: user
            content:
              - type: text
                text: What is the current president of Tanzania?
              - type: image_url
                image_url:
                  url: https://example.com/image.png
          type: object
          items:
            $ref: '#/components/schemas/AgentChatMessageAPI'
        agents:
          description: The list of agent IDs the main agent should use to respond
          example:
            - 2
            - 3
            - 4
          type: array
          items:
            type: number
        memoryChat:
          description: Previous messages in the conversation (as a JSON string)
          example:
            - role: user
              content:
                - type: text
                  text: Habari yako?
            - role: assistant
              content:
                - type: text
                  text: Nzuri sana, asante. Wewe je?
          type: array
          items:
            $ref: '#/components/schemas/ChatMessageAPI'
        temperature:
          type: number
          description: Sampling temperature
          default: 0.1
        top_p:
          type: number
          description: Nucleus sampling (top-p)
          default: 0.95
        max_tokens:
          type: number
          description: Maximum number of tokens in the response
          default: 4096
        frequency_penalty:
          type: number
          description: Penalty for repeated tokens
          default: 0.3
        presence_penalty:
          type: number
          description: Penalty for new topic tokens
          default: 0.3
        seed:
          type: number
          description: Random seed for reproducibility
          default: 2024
        stream:
          type: boolean
          description: Whether to stream the response
          default: false
        response_format:
          description: Optional response format specification
          example:
            type: json_schema
            json_schema:
              name: foo
              strict: true
              schema:
                type: object
                properties:
                  answer:
                    type: string
                    pattern: ^\d+$
                required:
                  - answer
                additionalProperties: false
          allOf:
            - $ref: '#/components/schemas/ResponseFormatDto'
      required:
        - name
        - description
        - instruction
        - intents
        - model
        - message
        - temperature
        - top_p
        - max_tokens
        - frequency_penalty
        - presence_penalty
        - seed
        - stream
    ChatRequestResponseDto:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Chat request processed successfully
        data:
          $ref: '#/components/schemas/ChatRequestData'
      required:
        - success
        - message
        - data
    ErrorResponse:
      required:
        - success
        - message
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: An error occurred
    AgentChatMessageAPI:
      type: object
      properties:
        role:
          type: string
          description: The role of the message sender
          enum:
            - user
          example: user
        content:
          type: array
          description: Content of the message
          example:
            - type: text
              text: Hello
          items:
            oneOf:
              - $ref: '#/components/schemas/TextContent'
              - $ref: '#/components/schemas/ImageContent'
      required:
        - role
        - content
    ChatMessageAPI:
      type: object
      properties:
        role:
          type: string
          description: The role of the message sender
          example: user
          enum:
            - user
            - system
            - assistant
            - tool
            - function
        content:
          type: array
          description: >-
            Content of the message as a list of typed blocks. For plain text,
            use an array with a text block, for example: [{ "type": "text",
            "text": "What is the current president of Tanzania?" }].
          example:
            - type: text
              text: What is the current president of Tanzania?
            - type: image_url
              image_url:
                url: https://example.com/image.png
          items:
            oneOf:
              - $ref: '#/components/schemas/TextContent'
              - $ref: '#/components/schemas/ImageContent'
      required:
        - role
        - content
    ResponseFormatDto:
      type: object
      properties:
        type:
          type: string
          description: The type of response format
          enum:
            - json_schema
          example: json_schema
        json_schema:
          type: object
          description: The JSON schema definition for the response
          example:
            name: foo
            strict: true
            schema:
              type: object
              properties:
                answer:
                  type: string
                  pattern: ^\d+$
              required:
                - answer
              additionalProperties: false
      required:
        - type
        - json_schema
    ChatRequestData:
      type: object
      properties:
        request:
          type: array
          items:
            $ref: '#/components/schemas/ChatRequest'
        created:
          type: string
          example: 1753304351
        model:
          type: string
          example: pawa-v1-blaze-20250318
        object:
          type: string
          example: chat.request
      required:
        - request
        - created
        - model
        - object
    TextContent:
      title: TextContent
      type: object
      properties:
        type:
          type: string
          enum:
            - text
          description: Type of the message content
        text:
          type: string
          description: Text content of the message
      required:
        - type
        - text
    ImageContent:
      title: ImageContent
      type: object
      properties:
        type:
          type: string
          enum:
            - image_url
          description: Type of the message content
        image_url:
          description: Image URL object
          allOf:
            - $ref: '#/components/schemas/ImageUrl'
      required:
        - type
        - image_url
    ChatRequest:
      type: object
      properties:
        finish_reason:
          type: string
          example: stop
        message:
          $ref: '#/components/schemas/ChatRequestMessage'
        matched_stop:
          type: number
          example: 106
      required:
        - finish_reason
        - message
        - matched_stop
    ImageUrl:
      type: object
      properties:
        url:
          type: string
      required:
        - url
    ChatRequestMessage:
      type: object
      properties:
        role:
          type: string
          example: assistant
        content:
          type: string
          example: Mimi ni pawa...
      required:
        - role
        - content
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````