Python SDK

The Python SDK connects directly to Neo4j over Bolt or to NAMS over HTTP. Supported methods, result shapes and data scope differ; see backend capabilities.

Neo4j Labs project

This project is part of Neo4j Labs and is actively maintained, but not officially supported. There are no SLAs or guarantees around backwards compatibility and deprecation. For questions and support, please use the Neo4j Community Forum.

Install Python 0.7.0

These Python examples use the published neo4j-agent-memory==0.7.0 package. Use Python 3.10 or later and install the extras needed by the selected backend and provider. For hosted NAMS memory:

python -m pip install 'neo4j-agent-memory[nams]==0.7.0'

For Aura with OpenAI embeddings, use python -m pip install 'neo4j-agent-memory[openai]==0.7.0'. Install the named provider/framework extra; [all] does not include every local model dependency. The linked tutorials include virtual-environment setup.

Each Python lesson displays its complete programs and helper modules with labelled filenames. Create the lesson folder, save those files locally, and install the SDK from PyPI. A repository clone is needed for SDK development; these Python lessons require neither a clone nor a code download.

Optional extras

Each extra adds the dependencies for one provider, integration or tool. Combine them in one install, for example python -m pip install 'neo4j-agent-memory[openai,cli]==0.7.0'.

Extras Enables

nams

The hosted NAMS backend (HTTP client).

openai, anthropic, bedrock, vertex-ai, litellm

Native model adapters for OpenAI, Anthropic, Amazon Bedrock and Vertex AI, and the LiteLLM fallback for other providers. aws is the same as bedrock; google is the same as vertex-ai.

sentence-transformers

Local embeddings, used by the keyless tutorials.

spacy, gliner2, extraction

Local entity extraction with spaCy, GLiNER2.5 (gliner2), or both (extraction). gliner is a deprecated alias of gliner2 that 0.8 removes.

instructor

An Instructor-backed structured extractor for LLM entity extraction.

fuzzy

RapidFuzz string matching for entity resolution and deduplication.

langchain, langchain-agents, pydantic-ai, llamaindex, crewai, openai-agents, microsoft-agent, google-adk, strands

Framework integrations. langchain installs langchain-core only; langchain-agents adds langchain for create_agent.

cli

The neo4j-agent-memory command line (extract, schemas, ontology, stats).

mcp

The MCP server started with neo4j-agent-memory mcp serve.

opentelemetry, opik, observability

Tracing providers for get_tracer(). opentelemetry includes the OTLP exporter; observability installs only the OpenTelemetry API and SDK.

all, full

all installs openai, anthropic, litellm, fuzzy, langchain, pydantic-ai, llamaindex, crewai, openai-agents and microsoft-agent. It does not include nams, mcp, cli, bedrock, vertex-ai, google-adk, strands, langchain-agents or the tracing extras. full adds spacy, gliner2, instructor and sentence-transformers.

The spaCy extractor also needs a language model: python -m spacy download en_core_web_sm.

Quick start

Choose one complete lesson with setup, named files and observable verification:

A complete lesson is the maintained starting point. A constructor change alone does not migrate data, configure every provider or guarantee backend parity.

Source and releases

Looking for the TypeScript SDK?

See TypeScript SDK. Python and TypeScript applications can share supported NAMS data in the same authorized workspace. This does not imply identical local APIs or automatic cross-process conversation recall.

Runnable examples

The examples directory contains small scripts, framework integrations and full applications. The tutorial and how-to pages display complete documentation recipes; larger applications have their own README dependencies and backend requirements. Application test fakes do not establish hosted service support for every demonstrated business operation.