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 SystemsThis notebook covers how to get started with the SurrealDB vector store.
- 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.
Setup
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:
-
Run with Docker.
Install dependencies
Installlangchain-surrealdb
and surrealdb
python packages.
Initialization
Manage vector store
Add items to vector store
Update items in vector store
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:API reference
For detailed documentation of all SurrealDBVectorStore features and configurations head to the API reference: python.langchain.com/api_reference/surrealdb/index.htmlNext steps
- look at the basic example. Use the Dockerfile to try it out!
- look at the graph example
- try the jupyther notebook
- Awesome SurrealDB, A curated list of SurrealDB resources, tools, utilities, and applications