Skip to content

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:

bash
# Using pnpm (recommended)
pnpm install

# Using npm
npm install

# Using yarn
yarn install

Core Package

The core package provides the main API and interfaces:

bash
pnpm add @graphrag-js/core

TIP

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:

bash
# 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/similarity

Storage Packages

In-Memory Storage (Development)

For development and testing, use the memory storage package:

bash
pnpm add @graphrag-js/memory

The memory package includes:

  • memoryGraph() - In-memory graph using Cytoscape
  • memoryVector() - In-memory vector store with cosine similarity
  • memoryKV() - In-memory key-value store
  • jsonKV() - File-based JSON key-value store
  • jsonGraph() - File-based JSON graph store

External Storage (Production)

For production deployments, install external storage adapters:

bash
# 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/redis

AI SDK Provider

GraphRAG.js uses the Vercel AI SDK for LLM and embedding models. Install your preferred provider:

bash
# 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/mistral

Minimal Installation

For a quick start with the similarity graph algorithm and in-memory storage:

bash
pnpm add @graphrag-js/core @graphrag-js/similarity @graphrag-js/memory ai @ai-sdk/openai

For a complete setup with LightRAG (default algorithm) and in-memory storage:

bash
pnpm add @graphrag-js/core @graphrag-js/lightrag @graphrag-js/memory ai @ai-sdk/openai

TypeScript Configuration

GraphRAG.js requires TypeScript 5.0 or later. Add this to your tsconfig.json:

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:

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

Verification

Verify your installation by running this simple test:

typescript
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

Released under the Elastic License 2.0.