> ## 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 Neo4J Knowledge Graph

> Upload a PDF or document file and define the schema prompt to train a knowledge graph in a Neo4J database.



## OpenAPI

````yaml post /knowledge_graph/neo4j/
openapi: 3.0.3
info:
  title: Lyzr Knowledge Graph - Train Neo4J
  version: 1.0.0
  description: >-
    Upload a document to generate a Knowledge Graph using Neo4J from the
    provided RAG system.
servers:
  - url: https://rag-prod.studio.lyzr.ai/v4
security: []
paths:
  /knowledge_graph/neo4j/:
    post:
      summary: Train Neo4J Knowledge Graph
      description: >-
        Upload a PDF or document file and define the schema prompt to train a
        knowledge graph in a Neo4J database.
      operationId: trainNeo4jKG
      parameters:
        - name: rag_id
          in: query
          required: true
          description: The ID of the RAG system to train
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: The document file (PDF or DOCX) to upload
                schema_prompt:
                  type: string
                  description: Allowed nodes and relationships for the knowledge graph
                extra_info:
                  type: string
                  description: Optional metadata or config in JSON string format
              required:
                - file
      responses:
        '200':
          description: Knowledge graph training completed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Knowledge Graph trained successfully using Neo4J.
                  rag_id:
                    type: string
                    example: 6848ff3c4c291b4bef798e0c
                  nodes_created:
                    type: integer
                    example: 142
                  relationships_created:
                    type: integer
                    example: 315
        '403':
          description: Forbidden - Invalid API key or permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Invalid permission
        '422':
          description: Validation Error - Input format or missing fields
          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
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````