Authenticationcdb_ memory · cbe_ Memory CI
Server-side only
FormatJSON over HTTPS
OpenAPI 3.1
Cloud quickstart
Remember one detail. Check one action.
Create a free Cloud account, make one project key, and run this
from server code. No card is required. Keep the key out of browsers and
mobile apps.
1. Create an account and project.Create a free Cloud account, then copy the project key when it is shown once.
2. Add the key to server-side secrets.
export CONTEXTDB_API_KEY="your-project-key"
3. Install the official Python client.
pip install contextdb-cloud-client==0.2.0a2
quickstart.py
import asyncio
import os
from contextdb_cloud_client import CloudClient
async def main():
async with CloudClient(
"https://api.contextdb.ai",
api_key=os.environ["CONTEXTDB_API_KEY"],
) as db:
saved = await db.remember(
"synthetic_customer_42",
"Thursday afternoon is confirmed.",
source="user_stated",
confidence=0.95,
idempotency_key="quickstart-remember-v1",
)
recalled = await db.recall(
"synthetic_customer_42",
"When is the visit?",
min_memory_version=saved.memory_version,
min_primary_wal_lsn=saved.primary_wal_lsn,
)
decision = await db.evaluate_action(
"synthetic_customer_42",
"book the visit",
)
print(recalled.memories[0].content, decision.outcome)
if decision.outcome == "act":
await db.report_execution(
"synthetic_customer_42",
decision.decision_id,
"appointment.book",
"succeeded",
idempotency_key=f"receipt-{decision.decision_id}",
)
asyncio.run(main())
Thursday afternoon is confirmed. act
ContextDB returns act, ask, or
abstain. Your host still authenticates the end user,
authorizes the business action, checks current state, and decides what
runs. Cloud currently has no availability SLA.
Runnable framework starters
Copy a complete agent memory integration.
Each public starter installs the official ContextDB client, uses a
stable server-side user partition, recalls before the model answers, and
keeps evidence evaluation outside the prompt.
Validate the selected user_id, query, and expected
act/ask/abstain outcome in the
Playground before
connecting a consequential side effect in a bounded alpha evaluation.
See the evidence path in Console
Follow one evidence evaluation from policy to host result.
Start with recall for action, then
use the guides to inspect changing memory, release checks, and source
syncs.
Synthetic demoHosted Alpha Console trace connecting the policy result, evidence snapshot, and host-reported receipt.
Use the Python or server-only TypeScript SDK to add persistent,
action-aware memory to voice, support, and workflow agents. Both clients
cover recall, consistency tokens, evidence evaluation for proposed
actions, execution receipts, and verifiable deletion.
Python SDK
For FastAPI, Django, workers, notebooks, and Python agent runtimes.
Install from PyPI
pip install contextdb-cloud-client==0.2.0a2
from contextdb_cloud_client import CloudClient
async with CloudClient(
"https://api.contextdb.ai",
api_key="cdb_...",
) as db:
saved = await db.remember(
"caller-1",
"Tuesday morning works best",
source="user_stated",
idempotency_key="call-42-preference",
)
Choose Python for Python agent runtimes and TypeScript for Node.js
backends. Use pycontextdb
instead when you want the Apache-2.0 local or self-hosted memory engine.
Can I use a ContextDB project key in browser code?
No. A cdb_ key is a server credential. Keep it in backend
secret storage and call ContextDB only from trusted server code.
Build with your coding agent
Open a complete ContextDB integration prompt.
Each button copies the prompt and opens it prefilled. Nothing is sent
until you review and submit it.
ContextDB integration prompt
Preview prompt
Integrate ContextDB Cloud into this repository.
Read:
- https://contextdb.ai/docs
- https://contextdb.ai/openapi.yaml
Use https://api.contextdb.ai and the server-side CONTEXTDB_API_KEY environment
variable. Never expose the project key in browser or mobile code.
Implement:
1. Recall customer memory when a call, chat, or agent session starts.
2. Write selected durable facts with their real source. For a
production-shaped Hosted Alpha evaluation, submit structured turns to
/v1/formation/jobs and poll the returned job ID. Use /v1/extract_memories
only for short synchronous flows.
3. Use mode=propose for review or mode=commit for automatic validated writes.
4. Use /v1/evolve for explicit ADD, UPDATE, DELETE, or NOOP operations. Pass
the returned memory version and WAL position into an immediate recall.
5. Call the Python client's evaluate_action before a booking, refund, plan
change, or write. Its HTTP route and MCP tool are named recall_for_action.
6. Branch on act, ask, or abstain. On ask, the customer host authenticates and
retains any end-user attestation, calls /v1/confirm for one returned pending
memory ID, and re-evaluates. On abstain, do not act.
7. On act, apply current-state checks and authorization in the customer host,
then run the host action.
8. Report succeeded, failed, or skipped with report_execution in the client,
POST /v1/receipts over HTTP, and the decision_id.
9. Use /v1/forget for one scoped memory, one stable slot, or verified
whole-partition erasure.
10. Test cross-user isolation, evolution evidence IDs, policy violations, and
named formation failures.
Inspect the repository first and show the proposed integration points before editing.
If the selected app is not installed, the prompt is still copied.
Getting started
Authentication
Project keys begin with cdb_. They select an organization
and project, and belong only in server-side secret storage.
user_id selects an isolated customer-memory partition. It
is not end-user authentication.
Memory CI tokens begin with cbe_. Each token is bound to
one project, shown once, and stored hashed. It is accepted only by the
four /evals/v1 operations. It cannot call memory routes or
create, read, update, or delete Testbench cases and suites.
Malformed JSON, missing field, or validation failure
401
Missing, unknown, or revoked project key
403
Project is not entitled to the requested feature
404
Missing target or target outside the caller's partition
413
Body, batch, turns, or transcript exceeds a cap
429
Client IP or project exceeded its request rate
502-504
Formation provider returned a named terminal failure
Rate limits
Both buckets apply: 120 requests per minute per client IP (burst 30),
then 600 requests per minute per authenticated project (burst 100).
Header
Meaning
Retry-After
Seconds to wait after a 429
X-RateLimit-Limit
Sustained requests per minute
X-RateLimit-Remaining
Tokens remaining in the burst bucket
X-RateLimit-Scope
ip or project
Idempotent writes
Add an Idempotency-Key to remember, batch remember,
confirmation, or formation commit requests. Every Evolution operation,
every Formation job, every execution receipt, and whole-partition
erasure require one. Use a new key for each logical mutation.
Situation
Result
Same key + same request
Original status and JSON body replayed
Same key + different request
409 idempotency_conflict
Identical request still running
Waits, then replays. A timeout returns 409.
Process stopped during write
409 idempotency_ambiguous. Do not retry with a new key. Inspect current business state, then contact Support with the request ID if the result is still unclear.
Responses are encrypted in the metadata store and expire after 24
hours. Per-project retention is capped at 100,000 records and 256 MiB.
Idempotency-Replayed is true on a replay.
SDKs expose this as idempotency_key in Python and
idempotencyKey in TypeScript.
Read your writes across runtimes
Remember, batch remember, evolve, confirm, and forget return a
project-scoped memory_version and
primary_wal_lsn. Pass them to the next ordinary recall
when that read must include the mutation.
The current deployment has no read replica: the read pool and primary
pool both connect to the primary.
readConsistency: "replica_fallback" (or
read_consistency over HTTP) remains an API consistency
contract for bounded replica wait and primary fallback in a topology
with a replica. It is not evidence of deployed read scaling. A
token-bearing recall uses the primary, and an impossible floor fails
with 503 consistency_unavailable. Evidence evaluation,
confirmations, deletion, and pending-memory reads also use the primary.
Apply one explicit factual-memory operation. ADD stores a new fact.
UPDATE supersedes a current target. DELETE removes a target or slot.
NOOP records why memory should remain unchanged.
Project + user scopedIdempotency-Key requiredAtomic state + revision + audit
Operation contract
add
Requires content and source. Does not accept a target.
update
Requires content, source, and either target_memory_id or an entity/attribute slot
delete
Accepts no content. Requires a target memory ID or slot.
noop
Accepts no content. Requires a bounded noop_reason.
UPDATE and DELETE fail closed when their target cannot be proven
inside the authenticated project and requested user partition.
Formation is Hosted Alpha. There is no audio upload, cancellation, job
listing, retention API, availability commitment, or public SLO.
Memory CI · Hosted Alpha
Run a pinned memory suite from CI.
These four operations use a project-bound cbe_ evaluation
token, not a cdb_ memory key. The token is accepted only
under /evals/v1 and cannot call memory routes or
Testbench case CRUD.
Poll aggregate status. Active states are queued,
running, retry_wait, and
cancelling. Terminal states are passed,
failed, error, and cancelled.
Regression state is no_baseline,
unchanged, or regressed.
Request cooperative cancellation. A queued run can become
cancelled before dispatch. Active work can remain
cancelling until it reaches a safe stopping point.
202 acceptedCooperative cancellationSafe status response
cURL
curl -X POST \
"$CONTEXTDB_BASE_URL/evals/v1/projects/$CONTEXTDB_PROJECT_ID/runs/$CONTEXTDB_EVAL_RUN_ID/cancel" \
-H "Authorization: Bearer $CONTEXTDB_EVAL_TOKEN"
Exports omit suite names, case names, queries, assertions, raw
failures, and memory content.
Public CLI and reusable Action
Install the exact package or pin the Action release.
The Apache-2.0
contextdb-memory-ci==0.1.0a1 package
was published through PyPI trusted publishing with attestations. The
exact registry artifact passed a fresh isolated install, import,
version, and --help check. The reusable Action is public in
the
memory-ci-action-v0.1.0 prerelease.
The Action installs exactly
contextdb-memory-ci==0.1.0a1. Store the
cbe_ token in GitHub Secrets. Project and suite IDs can
use GitHub Variables.
Exit
Meaning
0
Passed and unchanged, or a no-baseline pass only when explicitly allowed
1
Failed behavior or a regression
2
Operational error, cancellation, timeout, malformed response, output failure, or no baseline by default
Omit the baseline input to use the suite's pinned passing baseline.
JSON and JUnit artifacts are content-free: no suite or case names,
queries, assertions, raw failures, credentials, or memory content.
The public
strict contract
defines the accepted status and export fields.
The hosted service uses one dedicated single-instance Evals process
beside the Console API on the same VM. Leases, attempts, deadlines,
and bounded recovery are covered by real-PostgreSQL CI. This is process
isolation on one VM, not a worker fleet, HA, or failover. There is no
scheduling, availability SLA, or crash-resume availability claim.
Action shell and metadata tests do not establish an Action run inside
GitHub against production.
POST/v1/recall
Retrieve relevant memory for conversational grounding.
Project keyMaximum top_k 50
cURL
curl -X POST "$CONTEXTDB_BASE_URL/v1/recall" \
-H "Authorization: Bearer $CONTEXTDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "customer-123",
"query": "What should I know before this call?",
"top_k": 5
}'
Require a write token
{
"user_id": "customer-123",
"query": "What should I know before this call?",
"min_memory_version": 42,
"min_primary_wal_lsn": "1A/2B",
"read_consistency": "primary"
}
Record a durable evidence evaluation for a proposed action and return
what the policy says: act, ask, or
abstain. Use the returned decision_id when
the host reports what happened. In the Python client this operation is
evaluate_action. The HTTP route and MCP tool are both
named recall_for_action.
Project keyDecision recorded
cURL
curl -X POST "$CONTEXTDB_BASE_URL/v1/recall_for_action" \
-H "Authorization: Bearer $CONTEXTDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "customer-123",
"query": "Book the Saturday service appointment",
"top_k": 5
}'
Confirm one exact pending memory after the customer host authenticates
and retains any end-user attestation. API and MCP authenticate the
project credential, not the end user. The confirmation record binds
that caller and project context to the scoped memory. It does not prove
objective truth. Re-evaluate the action after confirming.
Close the loop after the host executes, fails, or skips an action.
ContextDB stores the host report. It does not inspect the downstream
system. Executing after ask or abstain is
retained as a policy violation.
Project + user scopedIdempotency-Key requiredStructured metadata only
Stateless JSON-RPC endpoint exposing remember, recall,
recall_for_action, pending confirmations, confirm, and scoped forget
as MCP tools. Whole-partition erasure stays on HTTP and the console.
Register signed decision webhooks and manage keys, approvals, members,
and projects in ContextDB Cloud.
Webhook payloads carry decisions, structured execution receipts, and
memory IDs, never memory content.