Python SDK Overview

February 25, 2026 ยท View on GitHub

The cgr package provides short imports for programmatic use of Code-Graph-RAG.

Installation

pip install code-graph-rag

With semantic code search:

pip install 'code-graph-rag[semantic]'

Quick Example

from cgr import load_graph

graph = load_graph("graph.json")
print(graph.summary())

functions = graph.find_nodes_by_label("Function")
for fn in functions[:5]:
    rels = graph.get_relationships_for_node(fn.node_id)
    print(f"{fn.properties['name']}: {len(rels)} relationships")

Available Modules

ImportPurpose
from cgr import load_graphLoad and query exported graph data
from cgr import MemgraphIngestorQuery Memgraph with Cypher directly
from cgr import CypherGeneratorGenerate Cypher from natural language
from cgr import embed_codeSemantic code search with UniXcoder
from cgr import settingsConfigure providers programmatically

Configuration

from cgr import settings

settings.set_orchestrator("openai", "gpt-4o", api_key="sk-...")
settings.set_cypher("google", "gemini-2.5-flash", api_key="your-key")

See individual pages for detailed API usage: