betterdb-ai
One install and one import root for the BetterDB AI stack on Valkey.
pip install betterdb-ai
Usage
from valkey.asyncio import Valkey
from betterdb_ai import AgentCache, SemanticCache, MemoryStore, Retriever
client = Valkey(host="localhost", port=6379)
cache = AgentCache(client=client)
This package adds no behaviour of its own. It depends on the five packages that make up the Python SDK and re-exports them:
| Package | What it gives you |
|---|---|
betterdb-agent-cache |
AgentCache — exact-match LLM, tool, and session tiers |
betterdb-semantic-cache |
SemanticCache — embedding-similarity cache |
betterdb-retrieval |
Retriever — index lifecycle, upsert, vector + filtered query |
betterdb-agent-memory |
AgentMemory, MemoryStore — long-term recall |
betterdb-valkey-search-kit |
shared FT.* helpers |
Each keeps its own name, version, and release workflow. Install them directly instead if you only need one.
Framework adapters
| Import | Provides |
|---|---|
betterdb_ai.langchain |
BetterDBLlmCache, BetterDBSemanticCache |
betterdb_ai.langgraph |
BetterDBSaver, BetterDBSemanticStore |
betterdb_ai.openai |
prepare_params, prepare_semantic_params |
betterdb_ai.openai_responses |
prepare_params, prepare_semantic_params |
betterdb_ai.anthropic |
prepare_params, prepare_semantic_params |
betterdb_ai.llamaindex |
prepare_params, prepare_semantic_params |
betterdb_ai.openai_agents |
prepare_params, CachedModel, CachedModelProvider |
betterdb_ai.pydantic_ai |
prepare_params, CachedModel |
openai_agents and pydantic_ai are agent-cache only — there is no semantic
counterpart, so those two modules have no prepare_semantic_params. There is no
vercel module: the Vercel AI SDK is TypeScript, and only @betterdb/ai has one.
Install the matching framework yourself, or take the extra:
pip install "betterdb-ai[langchain]"
| Extra | Pulls |
|---|---|
openai |
openai |
anthropic |
anthropic |
langchain |
langchain-core, langchain-openai |
langgraph |
langgraph |
llamaindex |
llama-index-core |
openai_agents |
openai-agents |
pydantic_ai |
pydantic-ai-slim |
normalizer |
aiohttp |
bedrock |
boto3 |
httpx |
httpx |
all |
every one of the above |
Each extra fans out to the same extra on every child that declares it, so
betterdb-ai[langchain] covers both caches' LangChain adapters.
Embedding functions
SemanticCache needs an embed_fn to turn text into a vector. Bring your own,
or use one of the provider-backed factories:
| Import | Provides | Needs |
|---|---|---|
betterdb_ai.embed.openai |
create_openai_embed |
[openai] |
betterdb_ai.embed.bedrock |
create_bedrock_embed |
[bedrock] |
betterdb_ai.embed.voyage |
create_voyage_embed |
[httpx] |
betterdb_ai.embed.cohere |
create_cohere_embed |
[httpx] |
betterdb_ai.embed.ollama |
create_ollama_embed |
[httpx] |
betterdb_ai.embed.google |
create_google_embed |
[httpx] |
from betterdb_ai import SemanticCache, SemanticCacheOptions
from betterdb_ai.embed.openai import create_openai_embed
cache = SemanticCache(SemanticCacheOptions(client=client, embed_fn=create_openai_embed()))
Namespaces
Twenty-two names are declared by more than one underlying package as a
different object, so they are not exported flat. Flattening one would silently
break except and isinstance for the other — ValkeyCommandError is a
genuinely different class in each cache. Reach those through the namespace for
the package you mean:
import asyncio
from betterdb_ai import AgentCache, agent_cache, semantic_cache
async def main() -> None:
cache = AgentCache(client=client)
try:
await cache.llm.check(model="claude-sonnet-4-5", messages=[...])
except agent_cache.ValkeyCommandError:
# agent-cache errors extend AgentCacheError
...
except semantic_cache.ValkeyCommandError:
# semantic-cache's ValkeyCommandError extends Exception — a different
# class that happens to share the name
...
asyncio.run(main())
The five namespaces are agent_cache, semantic_cache, retrieval, memory,
and search_kit. Every name a child declares stays reachable through them, so
nothing is lost by not being flat. betterdb_ai.AMBIGUOUS lists the names this
applies to and betterdb_ai.NAMESPACES the five modules.
A name that two packages export but that resolves to the same object is not
ambiguous and is flattened once — betterdb_semantic_cache re-exports
escape_tag, encode_float32, decode_float32, and parse_ft_search_response
straight from betterdb_valkey_search_kit.
Versioning
betterdb-ai pins the five children to exact == versions resolved from PyPI
at publish time, so a given facade release names exactly the child versions it
was tested against. Every automatic bump is a patch bump, which means a child's
breaking release can arrive under a facade version that looks compatible. Read
the children's changelogs, not just this one, until the facade leaves 0.x.
The Python and TypeScript SDKs version independently. betterdb-ai 0.1.0
and @betterdb/ai 0.1.0 are not the same surface, and
betterdb-semantic-cache and @betterdb/semantic-cache do not track each other
either. Compare the packages you actually installed rather than assuming parity
across ecosystems.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 betterdb_ai-1.0.0.tar.gz.
File metadata
- Download URL: betterdb_ai-1.0.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1db0dd74c7bc8856f491c2199d6354d6b799499d2523b5d09e64a70f950dc555
|
|
| MD5 |
814695b4d61903116fd3322c2119f13b
|
|
| BLAKE2b-256 |
44708cc7ba00775d8801fd831d36f949c8dedf21c4d13a09b0f13b105f520b2d
|
Provenance
The following attestation bundles were made for betterdb_ai-1.0.0.tar.gz:
Publisher:
ai-py-facade-release.yml on BetterDB-inc/monitor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
betterdb_ai-1.0.0.tar.gz -
Subject digest:
1db0dd74c7bc8856f491c2199d6354d6b799499d2523b5d09e64a70f950dc555 - Sigstore transparency entry: 2614003656
- Sigstore integration time:
-
Permalink:
BetterDB-inc/monitor@809efc9c644effe9c350f2de995afa29309ff144 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BetterDB-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ai-py-facade-release.yml@809efc9c644effe9c350f2de995afa29309ff144 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file betterdb_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: betterdb_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c79b79ff1a9f179a6b69af9c531e15bf4721c16b5368228f5cf19ad51d208286
|
|
| MD5 |
ee14d55527bb5e0ce98a008c7c38d8aa
|
|
| BLAKE2b-256 |
c9e125559a209ae1571d9c10f955f06181482d5e3a741d80b6a818a88fef2f5c
|
Provenance
The following attestation bundles were made for betterdb_ai-1.0.0-py3-none-any.whl:
Publisher:
ai-py-facade-release.yml on BetterDB-inc/monitor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
betterdb_ai-1.0.0-py3-none-any.whl -
Subject digest:
c79b79ff1a9f179a6b69af9c531e15bf4721c16b5368228f5cf19ad51d208286 - Sigstore transparency entry: 2614003706
- Sigstore integration time:
-
Permalink:
BetterDB-inc/monitor@809efc9c644effe9c350f2de995afa29309ff144 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BetterDB-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ai-py-facade-release.yml@809efc9c644effe9c350f2de995afa29309ff144 -
Trigger Event:
workflow_dispatch
-
Statement type: