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

# Retrieve

> Searches the RAG system's knowledge base using a query and returns the most relevant documents based on the specified retrieval method.



## OpenAPI

````yaml get /rag/{rag_id}/retrieve/
openapi: 3.0.3
info:
  title: Lyzr RAG Retrieval
  version: 1.0.0
  description: >-
    API endpoint for querying a RAG system and retrieving relevant document
    chunks based on various retrieval strategies.
servers:
  - url: https://rag-prod.studio.lyzr.ai/v3
security: []
paths:
  /rag/{rag_id}/retrieve/:
    get:
      summary: Retrieve
      description: >-
        Searches the RAG system's knowledge base using a query and returns the
        most relevant documents based on the specified retrieval method.
      operationId: retrieveDocuments
      parameters:
        - name: rag_id
          in: path
          required: true
          description: >-
            The unique identifier (ID) of the RAG system to query (must be a
            24-character hex string).
          schema:
            type: string
            example: 654c602a46c3b6d4e28741b0
        - name: query
          in: query
          required: true
          description: The search query string used to retrieve documents.
          schema:
            type: string
            example: type the necessary query
        - name: top_k
          in: query
          required: true
          description: The maximum number of top relevant documents to return.
          schema:
            type: integer
            example: 10
        - name: lambda_param
          in: query
          required: true
          description: Factor for Maximum Marginal Relevance (MMR) trade-off (0.0 to 1.0).
          schema:
            type: number
            format: float
            example: 0.6
        - name: retrieval_type
          in: query
          required: true
          description: The retrieval strategy to use.
          schema:
            type: string
            enum:
              - basic
              - mmr
              - hyde
              - time_aware
            example: basic
        - name: score_threshold
          in: query
          required: true
          description: Minimum score required for a document to be included (0.0 to 1.0).
          schema:
            type: number
            format: float
            example: 0
        - name: time_decay_factor
          in: query
          required: true
          description: Factor for time-aware retrieval to weight newer documents higher.
          schema:
            type: number
            format: float
            example: 0.7
      responses:
        '200':
          description: Documents successfully retrieved.
          content:
            application/json:
              schema:
                type: string
                description: >-
                  Placeholder for the retrieved document structure (typically a
                  list of Document objects with relevance scores).
        '422':
          description: Validation Error (e.g., query parameters not conforming to types).
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: array
                    items:
                      type: object
                      properties:
                        loc:
                          type: array
                          items:
                            oneOf:
                              - type: string
                              - type: integer
                        msg:
                          type: string
                        type:
                          type: string
        '500':
          description: Internal Server Error, typically due to an invalid RAG ID format.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: >-
                      Error: '123343' is not a valid ObjectId, it must be a
                      12-byte input or a 24-character hex string
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````