The official SurrealDB components for LangChain
langchain-surrealdb
This package contains the LangChain integration with SurrealDB
SurrealDB is a unified, multi-model database purpose-built for AI systems. It combines structured and unstructured data (including vector search, graph traversal, relational queries, full-text search, document storage, and time-series data) into a single ACID-compliant engine, scaling from a 3 MB edge binary to petabyte-scale clusters in the cloud. By eliminating the need for multiple specialized stores, SurrealDB simplifies architectures, reduces latency, and ensures consistency for AI workloads.
Why SurrealDB Matters for GenAI Systems
- One engine for storage and memory: Combine durable storage and fast, agent-friendly memory in a single system, providing all the data your agent needs and removing the need to sync multiple systems.
- One-hop memory for agents: Run vector search, graph traversal, semantic joins, and transactional writes in a single query, giving LLM agents fast, consistent memory access without stitching relational, graph and vector databases together.
- In-place inference and real-time updates: SurrealDB enables agents to run inference next to data and receive millisecond-fresh updates, critical for real-time reasoning and collaboration.
- Versioned, durable context: SurrealDB supports time-travel queries and versioned records, letting agents audit or “replay” past states for consistent, explainable reasoning.
- Plug-and-play agent memory: Expose AI memory as a native concept, making it easy to use SurrealDB as a drop-in backend for AI frameworks.
Installation
Python 3.10+ is required.
# -- Using pip
pip install -U langchain-surrealdb surrealdb
# -- Using uv (preferred for contributors)
uv add langchain-surrealdb surrealdb
Graph QA extra
Experimental graph QA helpers depend on langchain-classic. Install the extra if you
plan to use them:
pip install -U "langchain-surrealdb[graph-qa]"
Local development with uv
# install all dependency groups and extras
uv sync --all-groups --all-extras
# run the test suite
uv run pytest
# run formatting + lint checks
make lint
To exercise the included examples:
cd examples/basic && uv sync && uv run python main.pycd examples/graph && uv sync && uv run python graph.py
Requirements
You can run SurrealDB locally or start with a free SurrealDB cloud account.
For local, two options:
- Install SurrealDB and run SurrealDB. Run in-memory with:
surreal start -u root -p root
docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start
Simple example
from langchain_core.documents import Document
from langchain_surrealdb.vectorstores import SurrealDBVectorStore
from langchain_ollama import OllamaEmbeddings
from surrealdb import Surreal
conn = Surreal("ws://localhost:8000/rpc")
conn.signin({"username": "root", "password": "root"})
conn.use("langchain", "demo")
vector_store = SurrealDBVectorStore(OllamaEmbeddings(model="llama3.2"), conn)
doc_1 = Document(page_content="foo", metadata={"source": "https://surrealdb.com"})
doc_2 = Document(page_content="SurrealDB", metadata={"source": "https://surrealdb.com"})
vector_store.add_documents(documents=[doc_1, doc_2], ids=["1", "2"])
results = vector_store.similarity_search_with_score(
query="surreal", k=1, custom_filter={"source": "https://surrealdb.com"}
)
for doc, score in results:
print(f"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]")
Next steps
- look at the basic example. Use the Dockerfile to try it out!
- look at the graph example
- try the jupyter notebook
- Awesome SurrealDB, A curated list of SurrealDB resources, tools, utilities, and applications
Metadata
Release files for langchain-surrealdb 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_surrealdb-0.2.1.tar.gz | 17.6 kB | With provenance | Details for langchain_surrealdb-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_surrealdb-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for langchain_surrealdb-0.2.1-py3-none-any.whl |
Total release size: 35.0 kB
Release files / langchain_surrealdb-0.2.1.tar.gz
| Download URL | langchain_surrealdb-0.2.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c9f2eadab3e71b3083c6064eba7ea2f06b9f3f2b0c88742295970a124e47fd5
|
|
BLAKE2b-256 checksum How to use checksums |
6171a58bf902c70ff3ddfb1fc71f1e52ebd96025a7c24a041b3ec3cdc9d04b53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logRelease files / langchain_surrealdb-0.2.1-py3-none-any.whl
| Download URL | langchain_surrealdb-0.2.1-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ab89cdd86bb4825d9d827cf10b3a685c8a2fa09c136a2700c94f6b2cdb984de
|
|
BLAKE2b-256 checksum How to use checksums |
3d85ae0f9c9eeec33d068d3eed991b4b02c86bbd8936fbcc94797f5ff8e847d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logSecurity for langchain-surrealdb 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for langchain_surrealdb-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.