> ## 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.

# Train Text

> Process raw text data and use it to train the specified RAG system.



## OpenAPI

````yaml post /train/text/
openapi: 3.0.3
info:
  title: Lyzr Knowledge Base - Train Text
  version: 1.0.0
  description: >-
    Accepts raw text data, processes it into chunks, and trains the specified
    RAG system.
servers:
  - url: https://rag-prod.studio.lyzr.ai/v3
security: []
paths:
  /train/text/:
    post:
      summary: Train Text
      description: Process raw text data and use it to train the specified RAG system.
      operationId: trainText
      parameters:
        - name: rag_id
          in: query
          required: true
          description: >-
            The ID of the RAG system to train (must be a 24-character hex
            string).
          schema:
            type: string
            example: 654c602a46c3b6d4e28741b0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - data
                - chunk_size
                - chunk_overlap
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/TextData'
                  description: Array of text objects to be trained.
                chunk_size:
                  type: integer
                  description: Size of the chunks for text splitting.
                  example: 1000
                chunk_overlap:
                  type: integer
                  description: Overlap between consecutive text chunks.
                  example: 100
      responses:
        '200':
          description: Text successfully processed and RAG system trained.
          content:
            application/json:
              schema:
                type: string
                description: Placeholder for a success message or job ID.
        '422':
          description: >-
            Validation Error (e.g., missing required fields or incorrect data
            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 or application-specific error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: >-
                      Training Error: '123443' is not a valid ObjectId, it must
                      be a 12-byte input or a 24-character hex string
      security:
        - ApiKeyAuth: []
components:
  schemas:
    TextData:
      type: object
      properties:
        text:
          type: string
          description: The actual text content to be processed and chunked.
          example: string
        source:
          type: string
          description: Identifier for the source of the text (e.g., 'user_input').
          example: string
        extra_info:
          type: object
          description: Additional key-value metadata to associate with the text.
          example: {}
      required:
        - text
        - source
        - extra_info
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````