Zero-Context
A lightweight Python SDK for persistent, semantic AI agent memory powered by Google Gemini embeddings and PostgreSQL pgvector.
Installation
uv add zero-context
Or with pip:
pip install zero-context
Authentication
ZeroContext authenticates using an API key (zc_live_...). Pass it directly or set the ZERO_CONTEXT_API_KEY environment variable:
export ZERO_CONTEXT_API_KEY="zc_live_your_api_key"
Quickstart
from zero_context import MemoryConfig, ZeroContext
with ZeroContext(
api_key="zc_live_your_api_key",
config=MemoryConfig(default_top_k=5, similarity_threshold=0.0),
) as mem:
# 1. Add memories
ids = mem.add(
[
"User prefers Python and FastAPI.",
{"role": "user", "content": "I live in San Francisco."},
],
user_id="user_alice",
session_id="session_01",
)
# 2. Search memories
results = mem.search(
query="What stack does the user prefer?",
user_id="user_alice",
)
for match in results:
print(match.memory.text, match.score)
# 3. Update a memory
updated = mem.update(
memory_id=ids[0],
text="User prefers Python, FastAPI, and Go.",
)
# 4. Delete a memory
mem.delete(ids[1])
API Reference
ZeroContext(api_key=None, config=None, timeout=30.0)
Creates an SDK client instance.
api_key(str | None): Yourzc_live_...API key. Falls back toZERO_CONTEXT_API_KEY.config(MemoryConfig | None): Optional default search/configuration settings.timeout(float): HTTP request timeout in seconds (default30.0).
mem.add(content, user_id=None, session_id=None, metadata=None) -> list[str]
Ingests text, a sequence of strings, or chat message dicts ({"role": ..., "content": ...}) and returns a list of created memory IDs.
mem.search(query, user_id=None, session_id=None, limit=None, threshold=None, metadata_filter=None) -> list[SearchResult]
Runs semantic nearest-neighbor search and returns ranked SearchResult items (result.memory, result.score).
mem.update(memory_id, text, metadata=None) -> MemoryItem
Updates an existing memory's text (re-embedding it automatically) and optionally replaces its metadata.
mem.delete(memory_id) -> bool
Deletes a memory by ID. Returns True if deleted, or False if the record was not found.
Configuration (MemoryConfig)
| Field | Default | Description |
|---|---|---|
default_top_k |
5 |
Default maximum results returned by search() |
similarity_threshold |
0.0 |
Minimum cosine similarity score for search() |
dimension |
768 |
Embedding vector dimension |
max_context_chars |
1500 |
Maximum context character budget |
Error Handling
All SDK errors inherit from ZeroContextError:
ZeroContextError: Missing API key or general client configuration error.MemoryNotFoundError: Raised on404when updating a non-existent memory ID.StorageError: Raised on backend API errors (4xx/5xx).
License
MIT
Metadata
Release files for zero-context 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 |
|---|---|---|---|---|
| zero_context-0.2.1.tar.gz | 52.9 kB | Without provenance | Details for zero_context-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zero_context-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for zero_context-0.2.1-py3-none-any.whl |
Total release size: 59.0 kB
Release files / zero_context-0.2.1.tar.gz
| Download URL | zero_context-0.2.1.tar.gz |
|---|---|
| Size | 52.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a431de74d9e3382098b5116e58a0074bb5e0bea92150d7f9d853a6b3a7bdceb8
|
|
BLAKE2b-256 checksum How to use checksums |
73ef67d2142f9dc6f7b3e3bbe605ed32d8360cc7f601622eb4504e7679cad5ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / zero_context-0.2.1-py3-none-any.whl
| Download URL | zero_context-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
945202a4e1fdfb9ef5e69b93617fa61dca4f80c6ad5b4ea96469e16cfbab34d9
|
|
BLAKE2b-256 checksum How to use checksums |
0bb8eada4aeaf397122c497ddcd017d72734faf74d4d9a80adeaae9795913802
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for zero-context 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.