Installation
GraphRAG.js is designed as a collection of modular packages. Install only what you need.
Package Manager
We recommend using pnpm, but npm and yarn work too:
# Using pnpm (recommended)
pnpm install
# Using npm
npm install
# Using yarn
yarn installCore Package
The core package provides the main API and interfaces:
pnpm add @graphrag-js/coreTIP
The core package contains only interfaces and the Graph class. You'll need to install algorithm and storage packages separately.
Algorithm Packages
Choose one or more graph RAG algorithms:
# LightRAG (recommended default) - Dual-level retrieval
pnpm add @graphrag-js/lightrag
# Microsoft GraphRAG - Community detection
pnpm add @graphrag-js/microsoft
# Fast GraphRAG - PageRank retrieval
pnpm add @graphrag-js/fast
# AWS GraphRAG - Fact-centric graphs
pnpm add @graphrag-js/aws
# Similarity Graph - Simple baseline
pnpm add @graphrag-js/similarityStorage Packages
In-Memory Storage (Development)
For development and testing, use the memory storage package:
pnpm add @graphrag-js/memoryThe memory package includes:
memoryGraph()- In-memory graph using CytoscapememoryVector()- In-memory vector store with cosine similaritymemoryKV()- In-memory key-value storejsonKV()- File-based JSON key-value storejsonGraph()- File-based JSON graph store
External Storage (Production)
For production deployments, install external storage adapters:
# Neo4j graph database
pnpm add @graphrag-js/neo4j
# Qdrant vector database
pnpm add @graphrag-js/qdrant
# FalkorDB graph database
pnpm add @graphrag-js/falkordb
# PostgreSQL + pgvector
pnpm add @graphrag-js/pgvector
# Redis key-value store
pnpm add @graphrag-js/redisAI SDK Provider
GraphRAG.js uses the Vercel AI SDK for LLM and embedding models. Install your preferred provider:
# OpenAI
pnpm add ai @ai-sdk/openai
# Anthropic
pnpm add ai @ai-sdk/anthropic
# Google (Gemini)
pnpm add ai @ai-sdk/google
# Other providers
pnpm add ai @ai-sdk/cohere
pnpm add ai @ai-sdk/mistralMinimal Installation
For a quick start with the similarity graph algorithm and in-memory storage:
pnpm add @graphrag-js/core @graphrag-js/similarity @graphrag-js/memory ai @ai-sdk/openaiRecommended Installation
For a complete setup with LightRAG (default algorithm) and in-memory storage:
pnpm add @graphrag-js/core @graphrag-js/lightrag @graphrag-js/memory ai @ai-sdk/openaiTypeScript Configuration
GraphRAG.js requires TypeScript 5.0 or later. Add this to your tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}Environment Variables
Set up your API keys for the LLM provider:
# .env
OPENAI_API_KEY=your_openai_api_key
# Or for Anthropic
ANTHROPIC_API_KEY=your_anthropic_api_key
# Or for Google
GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_keyVerification
Verify your installation by running this simple test:
import { createGraph } from "@graphrag-js/core";
import { similarityGraph } from "@graphrag-js/similarity";
import { memoryStorage } from "@graphrag-js/memory";
import { openai } from "@ai-sdk/openai";
const graph = createGraph({
model: openai("gpt-4o-mini"),
embedding: openai.embedding("text-embedding-3-small"),
provider: similarityGraph(),
storage: memoryStorage(),
});
console.log("GraphRAG.js installed successfully!");Next Steps
- Quick Start - Build your first graph
- Core Concepts - Understand the architecture
- Algorithms - Choose the right algorithm