Getting Started with Graphiti and FalkorDB: A Practical Guide

Getting Started with Graphiti and FalkorDB: A Practical Guide

Read time: 2 minutes | Deployment time: <10 minutes

This post is a hands-on walkthrough for developers who want to get up and running with Graphiti and FalkorDB, fast. We’ll break things down with annotated code snippets, explain what makes Graphiti special, and show how it fits into a modern graph-powered knowledge system.

Whether you’re evaluating it for a new app or integrating it into an existing stack, this is your quick-start companion.

What is Graphiti?

FalkorDB role in Graphiti

Graphiti is a developer-friendly framework for building, querying, and managing knowledge graphs using episodes, which are structured or unstructured pieces of information (like JSON or text). It sits on top of a graph database like FalkorDB and adds:

  • Automatic entity and relationship extraction
  • Semantic and hybrid search out of the box
  • Built-in support for temporal knowledge
  • Recipes for advanced graph-based retrieval

Why FalkorDB?

FalkorDB is a high-performance in-memory graph database queryable with Cypher and is built for speed. It’s a natural fit for Graphiti, where you can think of FalkorDB as the infrastructure, and Graphiti as the intelligence layer on top.

Step 0: Set Up FalkorDB + Graphiti

You can launch a local FalkorDB instance in seconds with Docker:

				
					docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest
				
			

Next, install the Graphiti SDK which comes pre-integrated with  FalkorDB:

				
					pip install graphiti-core[falkordb]

# or, if you're using uv:
uv add graphiti-core[falkordb]

				
			

You’re now ready to connect, ingest data, and start querying your graph. Let’s go!

Step 1: Initialization

First, we connect to FalkorDB and set up logging.

				
					from graphiti_core import Graphiti
from graphiti_core.driver.falkordb_driver import FalkorDriver

falkor_driver = FalkorDriver(
    host='localhost',
    port='6379',
    username=None,
    password=None,
)
graphiti = Graphiti(graph_driver=falkor_driver)

await graphiti.build_indices_and_constraints()

build_indices_and_constraints()

				
			

Note: This sets up what Graphiti needs under the hood, like entity types, uniqueness constraints, search indices, and more.

Step 2: Add Your Knowledge

Let’s imagine you’re building a knowledge graph from internal HR records and team updates. You can mix structured data (e.g., org charts) with raw unstructured notes.

				
					from graphiti_core.nodes import EpisodeType
from datetime import datetime, timezone
import json

episodes = [
            {
                "content": "Alex Chen joined the AI Research team in May 2022 as a Senior ML Engineer reporting to Maria Gomez.",
                "type": EpisodeType.text,
                "description": "employee spotlight",
            },
            {
                "content": {
                    "name": "Maria Gomez",
                    "role": "Head of Product",
                    "start_date": "2019-03-01",
                    "reports_to": "CTO"
                },
                "type": EpisodeType.json,
                "description": "HR profile export",
            },
        ]

for i, ep in enumerate(episodes):
    await graphiti.add_episode(
        name=f"HR Episode {i}",
        episode_body=json.dumps(ep["content"]) if isinstance(ep["content"], dict) else ep["content"],
        source=ep["type"],
        source_description=ep["description"],
        reference_time=datetime.now(timezone.utc),
        group_id="internal-graph"
    )

				
			

Note: This sets up what Graphiti needs under the hood, like entity types, uniqueness constraints, search indices, and more.

Example of a knowledge graph created with Graphiti on FalkorDB
Example of a knowledge graph created with Graphiti on FalkorDB

Step 3: Ask Questions, Get Smart Answers

You don’t need a custom query language or fine-tuned model. Just ask:

				
					results = await graphiti.search("Who is the Head of Product?")
for r in results:
    print(r.fact)

				
			

Facts:
Maria Gomez is Head of Product.

Maria Gomez reports to CTO.

..

Behind the scenes, Graphiti performs:

  • Vector similarity search on embeddings
  • BM25 keyword retrieval
  • Ranks and merges the results
Example of episodes "facts" created with Graphiti on FalkorDB
Example of episodes "facts" created with Graphiti on FalkorDB

Step 4: Improve Context with Center Node Search

You can rerank results based on how close they are to a known entity, like “Maria Gomez”.

				
					center_node_uuid = results[0].source_node_uuid

reranked = await graphiti.search(
    "Who reports to the CTO?",
    center_node_uuid=center_node_uuid
)

				
			

Reranked Facts:

Maria Gomez reports to CTO.

Maria Gomez is Head of Product.

..

This boosts graph-relevant answers, great for tracing org hierarchies, process chains, or cause-effect paths.

Summary: Why Graphiti + FalkorDB?

Where context matters, graphs shine. By removing conventional blockers like working with structured and unstructured data and bypassing schema definition, getting started is streamlined and straightforward. 

With powerful hybrid search, graph-native context through reranking and both local and cloud deployment options, we can’t wait to see what you’ll build with this integration!

Build fast and accurate GenAI apps with GraphRAG-SDK at scale

FalkorDB offers an accurate, multi-tenant RAG solution based on our low-latency, scalable graph database technology. It’s ideal for highly technical teams that handle complex, interconnected data in real-time, resulting in fewer hallucinations and more accurate responses from LLMs.

Ultra-fast, multi-tenant graph database using sparse matrix representations and linear algebra, ideal for highly technical teams that handle complex data in real-time, resulting in fewer hallucinations and more accurate responses from LLMs.

USE CASES

SOLUTIONS

Simply ontology creation, knowledge graph creation, and agent orchestrator

Explainer

Explainer

Ultra-fast, multi-tenant graph database using sparse matrix representations and linear algebra, ideal for highly technical teams that handle complex data in real-time, resulting in fewer hallucinations and more accurate responses from LLMs.

COMPARE

Avi Tel-Or

CTO at Intel Ignite Tel-Aviv

I enjoy using FalkorDB in the GraphRAG solution I'm working on.

As a developer, using graphs also gives me better visibility into what the algorithm does, when it fails, and how it could be improved. Doing that with similarity scoring is much less intuitive.

Dec 2, 2024

Ultra-fast, multi-tenant graph database using sparse matrix representations and linear algebra, ideal for highly technical teams that handle complex data in real-time, resulting in fewer hallucinations and more accurate responses from LLMs.

RESOURCES

COMMUNITY