Installation
GraphRAG SDK 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-sdkTIP
The core package contains only interfaces, createGraph(), and query(). You'll need to install a provider package and storage separately.
Provider Packages
Choose a graph provider:
# Lexical Graph — entity extraction, community detection, search strategies
pnpm add @graphrag-sdk/lexicalThe lexical package includes composable processors and search strategies:
Processors (run during indexing):
chunkEntityGeneration()— extract entities and relationships from chunksentityCommunityGeneration()— Leiden clustering + community reportssimilarChunkConnection()— build similarity edges between chunkshypotheticalQuestionGeneration()— generate question embeddings per chunk
Search strategies (run during queries):
naiveSearch()— pure vector search baselineentityEnhancedSearch()— chunk search + entity graph traversallocalCommunitySearch()— entity neighborhood + community contextglobalCommunitySearch()— community reports for thematic queriessimilarChunkTraversalSearch()— BFS along SIMILAR_TO edgeshypotheticalQuestionSearch()— question-to-question matching
Presets (pre-configured pipelines):
microsoftGraphragPreset()— entities + communities (Microsoft GraphRAG)lightragPreset()— entities only (LightRAG)fastGraphragPreset()— entities + similarity edgesawsGraphragPreset()— entities + communities (AWS style)
Storage Packages
In-Memory Storage (Development)
For development and testing:
pnpm add @graphrag-sdk/in-memory-storageThe memory package includes:
inMemoryGraph()— in-memory graph using CytoscapeinMemoryVector()— in-memory vector store with cosine similarityinMemoryKV()— 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-sdk/neo4j
# Qdrant vector database
pnpm add @graphrag-sdk/qdrant
# FalkorDB graph database
pnpm add @graphrag-sdk/falkordb
# PostgreSQL + pgvector
pnpm add @graphrag-sdk/pgvector
# Redis key-value store
pnpm add @graphrag-sdk/redisAI SDK Provider
GraphRAG SDK 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/googleMinimal Installation
pnpm add graphrag-sdk @graphrag-sdk/lexical @graphrag-sdk/in-memory-storage ai @ai-sdk/openaiTypeScript Configuration
GraphRAG SDK 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:
import { createGraph, query } from "graphrag-sdk";
import { lexicalGraph, chunkEntityGeneration, naiveSearch } from "@graphrag-sdk/lexical";
import { inMemoryGraph, inMemoryVector, inMemoryKV } from "@graphrag-sdk/in-memory-storage";
import { openai } from "@ai-sdk/openai";
const graph = createGraph({
graph: lexicalGraph({
graphStoreFactory: inMemoryGraph,
vectorStoreFactory: inMemoryVector,
kvStoreFactory: inMemoryKV,
pipeline: [chunkEntityGeneration()],
}),
model: openai("gpt-4o-mini"),
embedding: openai.embedding("text-embedding-3-small"),
});
console.log("GraphRAG SDK installed successfully!");Next Steps
- Quick Start - Build your first graph
- Core Concepts - Understand the architecture