Install & Compatibility
Where this runs
tested against v1.17.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 276.2MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 11.4s · import 0.000s · 267MB
275MB installed
● package 275MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GraphRAGPipeline
✓ from neo4j_graphrag import GraphRAGPipeline
✗ from neo4j_graphrag import GraphRAGPipeline
This quickstart demonstrates how to set up and use the `GraphRAGPipeline` with an OpenAI LLM to query a Neo4j knowledge graph. It requires Neo4j to be running and accessible, and an OpenAI API key. Ensure `NEO4J_URI`, `NEO4J_USERNAME`, `NEO4J_PASSWORD`, and `OPENAI_API_KEY` environment variables are set.
import os
from neo4j import GraphDatabase
from neo4j_graphrag.graph_rag_pipeline import GraphRAGPipeline
from neo4j_graphrag.llm import OpenAILLM
# --- Configuration (Set environment variables or replace placeholders) ---
NEO4J_URI = os.environ.get("NEO4J_URI", "bolt://localhost:7687")
NEO4J_USERNAME = os.environ.get("NEO4J_USERNAME", "neo4j")
NEO4J_PASSWORD = os.environ.get("NEO4J_PASSWORD", "password")
NEO4J_DATABASE = os.environ.get("NEO4J_DATABASE", "neo4j")
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY", "") # Required for OpenAILLM
if not all([NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD, OPENAI_API_KEY]):
print("Warning: Please set NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD, and OPENAI_API_KEY environment variables for a runnable example.")
print("Using default values for Neo4j, which may not connect without a running instance.")
print("OpenAI API key is missing. The LLM initialization might fail or proceed without API calls.")
try:
# 1. Initialize Neo4j Driver
driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USERNAME, NEO4J_PASSWORD))
# Verify connection to ensure Neo4j is reachable and credentials are correct
driver.verify_connectivity()
print("Neo4j connection verified successfully.")
# 2. Initialize your chosen LLM (e.g., OpenAI)
llm = OpenAILLM(api_key=OPENAI_API_KEY)
# 3. Initialize the GraphRAG pipeline
# This pipeline is designed to work with a knowledge graph. For best results,
# ensure your Neo4j database has relevant data, possibly built using SimpleKGPipeline.
pipeline = GraphRAGPipeline(
llm=llm,
graph_driver=driver,
database=NEO4J_DATABASE
)
# 4. Ask a question to the pipeline
question = "Who is the CEO of Neo4j?"
print(f"\nQuestion: {question}")
response = pipeline.query(question)
print(f"Answer: {response.answer}")
except Exception as e:
print(f"An error occurred during quickstart: {e}")
finally:
if 'driver' in locals():
driver.close()
print("Neo4j driver closed.")
Upgrade
Version history
1.17.0latest on PyPI · released May 27, 2026
Audit
Dependencies
neo4jrequiredCore dependency for connecting to Neo4j database (requires >=5.19.0,<6.0.0)
openaioptionalFor using OpenAILLM
google-cloud-aiplatformoptionalFor using VertexAILLM
mistralaioptionalFor using MistralAILLM
ollamaoptionalFor using OllamaLLM
pypdfoptionalFor PDF document loading (e.g., PdfLoader)