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

# Query agent knowledge base

> Run the agent's current RAG retrieval for an ad hoc query and return ranked chunks without creating a conversation



## OpenAPI

````yaml /api-reference/openapi.json post /v1/convai/agents/{agent_id}/knowledge-base/rag-query
openapi: 3.1.0
info:
  title: Threetone API
  description: >-
    APIs for the Threetone Agents Platform and shared workspace resources.
    Authenticate programmatic requests with an API key in the x-api-key header.
  version: '1.0'
servers:
  - url: https://api.threetone.in
    description: Production
security: []
paths:
  /v1/convai/agents/{agent_id}/knowledge-base/rag-query:
    post:
      tags:
        - Agents Platform
      summary: Query agent knowledge base
      description: >-
        Run the agent's current RAG retrieval for an ad hoc query and return
        ranked chunks without creating a conversation
      operationId: query_agent_knowledge_base_rag_route
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            description: The id of an agent. This is returned on agent creation.
            examples:
              - agent_3701k3ttaq12ewp8b7qv5rfyszkz
            embed: true
            title: Agent Id
          description: The id of an agent. This is returned on agent creation.
        - name: branch_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The ID of the branch to use
            examples:
              - agtbranch_0901k4aafjxxfxt93gd841r7tv5t
            title: Branch Id
          description: The ID of the branch to use
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Your API key for programmatic access. Send it in the x-api-key
              header; you can create and manage keys from the Developers page.
            title: X-Api-Key
          description: >-
            Your API key for programmatic access. Send it in the x-api-key
            header; you can create and manage keys from the Developers page.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentKnowledgeBaseRagQueryRequestModel'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentKnowledgeBaseRagQueryResponseModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AgentKnowledgeBaseRagQueryRequestModel:
      properties:
        query:
          type: string
          minLength: 1
          title: Query
          description: Query to run against the agent's knowledge base RAG index.
          examples:
            - How do I reset my password?
        use_agent_defaults:
          type: boolean
          title: Use Agent Defaults
          description: >-
            When true (the default), retrieval uses the agent's own RAG
            settings, reproducing exactly what the agent would retrieve. Set to
            false to retrieve with neutral default RAG settings instead (the
            agent's embedding model is always kept, since it determines which
            vector index exists). Useful for auditing the knowledge base
            independently of how a particular agent is tuned.
          default: true
        max_documents_length:
          anyOf:
            - type: integer
              maximum: 50000
              exclusiveMinimum: 0
            - type: 'null'
          title: Max Documents Length
          description: >-
            Optional maximum total character length of document chunks returned.
            Overrides the selected RAG settings for this query only.
        max_retrieved_rag_chunks_count:
          anyOf:
            - type: integer
              maximum: 20
              exclusiveMinimum: 0
            - type: 'null'
          title: Max Retrieved Rag Chunks Count
          description: >-
            Optional maximum number of document chunks retrieved. Overrides the
            selected RAG settings for this query only.
      type: object
      required:
        - query
      title: AgentKnowledgeBaseRagQueryRequestModel
    AgentKnowledgeBaseRagQueryResponseModel:
      properties:
        retrieval_query:
          type: string
          title: Retrieval Query
          description: Raw query used for retrieval (echoes the request query).
        chunks:
          items:
            $ref: '#/components/schemas/AgentKnowledgeBaseRagChunkResponseModel'
          type: array
          title: Chunks
          description: >-
            Ranked chunks the agent would retrieve, after distance and length
            filtering.
      type: object
      required:
        - retrieval_query
        - chunks
      title: AgentKnowledgeBaseRagQueryResponseModel
      example:
        chunks:
          - chunk_id: chunk_498cjVigY5qzO86Huf0OWal
            content_format: html
            document_id: doc_J3Pbu5gP6NNKBscdCdwB
            document_name: Account FAQ
            document_type: url
            source_url: >-
              https://example.com/account-faq?utm_medium=agents_citation&utm_source=elevenlabs
            text: To reset your password, open Settings and choose Security...
            vector_distance: 0.21
        retrieval_query: How do I reset my password?
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentKnowledgeBaseRagChunkResponseModel:
      properties:
        document_id:
          type: string
          title: Document Id
          description: ID of the source knowledge base document.
        document_name:
          type: string
          title: Document Name
          description: Name of the source knowledge base document.
        source_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Url
          description: >-
            Tracked source URL for URL documents, or null for other document
            types.
        chunk_id:
          type: string
          title: Chunk Id
          description: ID of the retrieved chunk.
        text:
          type: string
          title: Text
          description: Text content of the retrieved chunk.
        vector_distance:
          anyOf:
            - type: number
            - type: 'null'
          title: Vector Distance
          description: Similarity distance when exposed by the retrieval strategy.
        content_format:
          $ref: '#/components/schemas/ContentFormat'
          description: >-
            Format of the chunk text. Markdown chunks contain raw markdown; HTML
            chunks contain HTML.
        document_type:
          $ref: '#/components/schemas/KnowledgeBaseDocumentType'
          description: Type of the source knowledge base document.
      type: object
      required:
        - document_id
        - document_name
        - source_url
        - chunk_id
        - text
        - vector_distance
        - content_format
        - document_type
      title: AgentKnowledgeBaseRagChunkResponseModel
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ContentFormat:
      type: string
      enum:
        - html
        - markdown
      title: ContentFormat
      description: >-
        Canonical representation of a knowledge base document's stored content.


        HTML is the legacy default; documents created before this field existed
        are

        interpreted as HTML.
      default: html
    KnowledgeBaseDocumentType:
      type: string
      enum:
        - file
        - url
        - text
        - folder
      title: KnowledgeBaseDocumentType

````