Strata — an embedded multi-model database for AI agents (Python SDK)
Project description
stratadb — Strata for Python
The Python SDK for Strata: an embedded multi-model database for AI agents. SQLite-shaped, not a server — it links the engine in process and opens a file-backed (or in-memory) database directly.
Six primitives — key-value, JSON documents, vectors, an event log, and a graph
— share one branch-aware, time-travelling storage substrate. The SDK speaks the
exact same command surface, value shapes, and error codes as the strata CLI
and MCP server, so learning one channel is learning all of them.
For coding agents — start here
Install with pip install stratadb, then call stratadb.agents_guide() first.
It returns the complete offline Python usage guide (every namespace, db.ai,
provider keys, branches / time-travel, errors — all runnable Python), so you can
learn the whole surface without probing it:
import stratadb
db = stratadb.open(cache=True) # ephemeral; or open("./app-data") for durable
print(stratadb.agents_guide()) # the entire surface, offline — read this first
python -m stratadb.demo— a runnable, zero-setup tour that prints every primitive's real return shape (doubles as a smoke test).stratadb.init("path/to/repo")— scaffold the Strata agent skill and anAGENTS.mdstanza into a repo so the next agent starts warm.
Names & surfaces
Strata appears under a few names; here is what each string is and where it's used:
| Surface | Value | Notes |
|---|---|---|
| PyPI package | stratadb |
pip install stratadb |
| Python import | import stratadb |
the SDK this README documents |
| CLI | strata |
a separate binary (strata-core); not installed by this wheel |
| MCP server | strata <db> mcp serve |
snippet via stratadb.mcp_config(path) |
| GitHub repo | stratalab/strata-python |
this SDK |
| GitHub org | stratalab |
|
| Website / docs | stratadb.org |
Install
pip install stratadb
No Rust toolchain required — wheels are prebuilt (abi3, one per platform,
Python 3.9+).
Quickstart
import stratadb
db = stratadb.open("./app-data") # durable (creates if absent)
# db = stratadb.open(cache=True) # ephemeral, in-memory
# Key-value
db.kv.put("greeting", "hello")
db.kv.get("greeting") # b"hello"
# JSON documents
db.json.set("user:1", "$", {"name": "Ada", "roles": ["admin"]})
db.json.get("user:1", "$.name") # "Ada"
# Vectors (similarity search with metadata filters)
from stratadb import filters
db.vectors.create_collection("notes", dimension=3)
db.vectors.upsert("notes", "n1", [0.1, 0.2, 0.3], metadata={"kind": "note"})
hits = db.vectors.query("notes", [0.1, 0.2, 0.3], k=5,
filter=filters.eq("kind", "note"))
# Events (append-only, hash-chained)
db.events.append("signup", {"user": "ada"})
# Graph
db.graphs.create("social")
db.graphs.add_node("social", "ada")
db.graphs.add_edge("social", "ada", "follows", "grace")
db.close() # or: with stratadb.open("./app-data") as db: ...
Strata() never opens the current directory implicitly: pass a path, set
STRATA_DB (stratadb.from_env()), or use cache=True.
Inference — db.ai
Chat, embeddings, and reranking over cloud providers (OpenAI, Anthropic, Google)
or local GGUF models — an OpenAI-shaped surface. Strata is embedded and ships no
keys: set OPENAI_API_KEY / ANTHROPIC_API_KEY / GOOGLE_API_KEY, or
strata config set openai.api_key sk-....
r = db.ai.chat("Explain embeddings in one sentence.",
model="openai:gpt-4o-mini", max_tokens=60)
print(r.content)
# Structured output (JSON Schema)
r = db.ai.chat("Capital of France and its population?",
model="anthropic:claude-haiku-4-5-20251001",
json_schema={"type": "object",
"properties": {"capital": {"type": "string"},
"population": {"type": "integer"}},
"required": ["capital", "population"]})
# Tool / function calling
r = db.ai.chat("What's the weather in Paris?", model="google:gemini-2.5-flash",
tools=[{"type": "function",
"function": {"name": "get_weather",
"parameters": {"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]}}}],
tool_choice="required")
r.tool_calls # [{'id': ..., 'function': {'name': 'get_weather', 'arguments': '{"city":"Paris"}'}}]
# Embeddings
e = db.ai.embed(["hello", "world"], model="openai:text-embedding-3-small")
e.vectors # [[...], [...]]
# A model handle sets load params once
qwen = db.ai.model("local:qwen3", n_ctx=8192)
qwen.chat("Summarize: ...")
db.ai.capability("openai:gpt-4o-mini") # supported features; no network call
Branches, spaces, and time travel
db.branches.fork("main", "experiment") # copy-on-write branch
exp = db.at(branch="experiment") # a scoped view over the same handle
exp.kv.put("k", "only-on-experiment")
receipt = db.kv.put("k", "v1")
db.kv.put("k", "v2")
db.kv.get("k", as_of=receipt.commit.timestamp) # b"v1" — every read takes as_of
Errors
Every failure raises a typed stratadb.errors.StrataError subclass carrying a
stable code, message, hint, and ref. Match on code, never on message:
from stratadb import errors
try:
db.at(branch="ghost").kv.get("k")
except errors.NotFoundError as e:
assert e.code == "not_found.engine.branch"
print(e.ref) # https://stratadb.org/e/not_found.engine.branch
Misses are not errors — reads return None.
For AI agents
stratadb.agents_guide()— the complete offline Python usage guide bundled in the wheel (the SDK-native counterpart tostrata agents guide).python -m stratadb.demo/stratadb.demo()— a runnable, zero-setup tour of every primitive with real printed output.stratadb.init(repo_path=".")— scaffold.claude/skills/strata/SKILL.mdand anAGENTS.mdstanza into a repo (idempotent).stratadb.agents_skill()— the Claude Code skill markdown (version-stamped).stratadb.command_index()— the full command catalog bundled in the wheel.stratadb.mcp_config(path)— the MCP client-config snippet (strata <path> mcp serve; needs thestratabinary, a separate strata-core install).db.execute(command: dict) -> dict— the raw command escape hatch (the same wire the CLI and MCP speak); the typed namespaces build on it.
Architecture
Three layers: handwritten ergonomic namespaces over a generated core (one typed method + model per command, generated from the engine's IDL) over a tiny PyO3 binding that links the engine in process. Data-plane only — generated fresh from the IDL, drift-guarded in CI.
Development
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest
maturin develop # builds the native binding into the venv
python tools/generate.py # regenerates the typed core from idl/v1/
pytest
Local builds use a path dependency to a sibling ../strata-core checkout;
releases pin the git rev in idl/v1/STRATA_CORE_REV (tools/release_prep.py).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stratadb-1.0.2.tar.gz.
File metadata
- Download URL: stratadb-1.0.2.tar.gz
- Upload date:
- Size: 256.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8388c4f541c4314b1ff46435555d86b2316315cdcc309f527ead857d7f7f0dec
|
|
| MD5 |
a06dd656229f181f3bbe98a92850c257
|
|
| BLAKE2b-256 |
1791acb770d1efa0a53a6c629ddb952b03290c225381695f97279a93b342aa78
|
Provenance
The following attestation bundles were made for stratadb-1.0.2.tar.gz:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2.tar.gz -
Subject digest:
8388c4f541c4314b1ff46435555d86b2316315cdcc309f527ead857d7f7f0dec - Sigstore transparency entry: 2218550310
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 9.4 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
063c38113ddd1b2a1300bb6e62c1a3a69a7420ca081e600cac916bd4b12b9efe
|
|
| MD5 |
5249139f8731ef53498214ba0fa5c22f
|
|
| BLAKE2b-256 |
c984115a91cef09f8bf2fa1dd2e4848bc749d93e50d26635493db7779ca225aa
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-win_amd64.whl -
Subject digest:
063c38113ddd1b2a1300bb6e62c1a3a69a7420ca081e600cac916bd4b12b9efe - Sigstore transparency entry: 2218550399
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 11.4 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ca68a1b464619cb8e4f5e1bc182f4c145196c919a029f777d2de52a4e7b9156
|
|
| MD5 |
660d5e5ef7ad29fc06b6d9f41e3b9c45
|
|
| BLAKE2b-256 |
762920969e6d4c317a0d1d6a4feb4ea83d0050b181da5171c5fb871784ed28a1
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
5ca68a1b464619cb8e4f5e1bc182f4c145196c919a029f777d2de52a4e7b9156 - Sigstore transparency entry: 2218550445
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 11.0 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae2159e18703f05e25a9395163d6e52e269fef50a9e6073af6534ed38ddc3c39
|
|
| MD5 |
419f2fb69dc2133145815c7478fae1bb
|
|
| BLAKE2b-256 |
54f2d6f8bc838fa166a8b3ac132681ec853d649d6d6d59c110d967f4cd286b1b
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
ae2159e18703f05e25a9395163d6e52e269fef50a9e6073af6534ed38ddc3c39 - Sigstore transparency entry: 2218550373
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 10.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df42c5b1ae18df0a9224ddb2fddd2678a5d0a302c7bb93b94527c582ef1db2da
|
|
| MD5 |
eea62a4538cbc5d65bcc88848b338999
|
|
| BLAKE2b-256 |
8775c27813065e62efcf5dbd12df16d4d408fd6d5042b5733b728cee87a0590a
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
df42c5b1ae18df0a9224ddb2fddd2678a5d0a302c7bb93b94527c582ef1db2da - Sigstore transparency entry: 2218550388
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a0ebb73b3dbdb275c96bd49a87e8854f594bda13c68292fe8446d47e9065538
|
|
| MD5 |
77b95cd8533cee02dcfee5dca75a844f
|
|
| BLAKE2b-256 |
36b5e761c72351f299c9919b92e888393b2c36077a38f58c7b1faf147739becb
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
0a0ebb73b3dbdb275c96bd49a87e8854f594bda13c68292fe8446d47e9065538 - Sigstore transparency entry: 2218550349
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.7 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eec552d177bfb48daf9308400ae219af1503580ff09b8a71571e6cc95e651870
|
|
| MD5 |
e3f08a07adc3052efb2805ea3db27645
|
|
| BLAKE2b-256 |
a19c7576f5794b1d0ded4e0bbc876eede2a30e9fba7a0c74859349062e4f7720
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
eec552d177bfb48daf9308400ae219af1503580ff09b8a71571e6cc95e651870 - Sigstore transparency entry: 2218550464
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file stratadb-1.0.2-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: stratadb-1.0.2-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82a96bd9df616f3959bd0de84fb6d3bfb7ab91f20911cf8418c90af573d9a8dc
|
|
| MD5 |
b17dfc493a8120565af1ce601b9ff0f8
|
|
| BLAKE2b-256 |
a1bf1d0d2104bb95b011aeb03ac016e8950f31916251d1a971d8180340539c8c
|
Provenance
The following attestation bundles were made for stratadb-1.0.2-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on stratalab/strata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stratadb-1.0.2-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
82a96bd9df616f3959bd0de84fb6d3bfb7ab91f20911cf8418c90af573d9a8dc - Sigstore transparency entry: 2218550416
- Sigstore integration time:
-
Permalink:
stratalab/strata-python@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/stratalab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf3200d2c8373f1b52526d15ed5f95a259254a5d -
Trigger Event:
release
-
Statement type: