> Use the Bilinc Python SDK with CloudClient for hosted commit, recall, revise, confirm, forget, history, list, export, snapshot, diff, rollback, and status.

Canonical page: https://bilinc.space/docs/python-sdk

- [Docs](https://bilinc.space/docs)
- Use Bilinc
- Python SDK

# Call verifiable memory from Python.

Use `CloudClient` when Bilinc sits inside your agent runtime and needs hosted project-isolated memory.

Search the docs

### All docs pages

Start

- [Overview](https://bilinc.space/docs)
- [Quickstart](https://bilinc.space/docs/quickstart)
- [Cloud quickstart](https://bilinc.space/docs/cloud-quickstart)
- [Quicktest help](https://bilinc.space/docs/quicktest-troubleshooting)
- [v2 migration](https://bilinc.space/docs/migration-v2)

Use Bilinc

- [Python SDK](https://bilinc.space/docs/python-sdk)
- [CLI](https://bilinc.space/docs/cli)
- [Cloud API](https://bilinc.space/docs/api-reference)
- [MCP integration](https://bilinc.space/docs/mcp)
- [Remote MCP for Claude](https://bilinc.space/docs/remote-mcp)
- [MCP tools](https://bilinc.space/docs/mcp-tools)
- [Wiki export](https://bilinc.space/docs/wiki)
- [Dream pass](https://bilinc.space/docs/dream)
- [Agent recipes](https://bilinc.space/docs/agent-recipes)

Agent integrations

- [Codex](https://bilinc.space/docs/codex)
- [Claude Code](https://bilinc.space/docs/claude-code)
- [Cursor](https://bilinc.space/docs/cursor)
- [MCP clients](https://bilinc.space/docs/mcp-clients)

Concepts

- [Memory model](https://bilinc.space/docs/memory-model)
- [Commit and recall](https://bilinc.space/docs/commit-recall)
- [Entitlements](https://bilinc.space/docs/entitlements)
- [Recall profiles](https://bilinc.space/docs/recall-profiles)
- [Evidence-aware recall](https://bilinc.space/docs/evidence-aware-recall)
- [Snapshots and rollback](https://bilinc.space/docs/snapshots-rollback)
- [Audit trail](https://bilinc.space/docs/audit-trail)

Operate

- [Security](https://bilinc.space/docs/security)
- [Production checklist](https://bilinc.space/docs/production-checklist)
- [Operations](https://bilinc.space/docs/operations)
- [Errors](https://bilinc.space/docs/errors)
- [Rate limits](https://bilinc.space/docs/rate-limits)
- [Troubleshooting](https://bilinc.space/docs/troubleshooting)

Reference

- [Environment variables](https://bilinc.space/docs/environment-variables)
- [CLI reference](https://bilinc.space/docs/cli-reference)

Also

- [Pricing](https://bilinc.space/pricing)
- [Changelog](https://bilinc.space/changelog)
- [Connect over MCP](https://bilinc.space/mcp)

## Import `CloudClient`, then write, recall, and inspect hosted state.

Python

```
import os
from bilinc import CloudClient

client = CloudClient(api_key=os.environ["BILINC_API_KEY"])

client.commit("user.preference", {"theme": "dark"})
results = client.recall("user preference", limit=5)

# What can this key do? (authenticated, never billed)
status = client.status()

# Is the service reachable? (public service health)
health = client.health()
```

## Write, correct, checkpoint, inspect, forget, recover.

Python

```
import os
from bilinc import CloudClient

client = CloudClient(api_key=os.environ["BILINC_API_KEY"])

# 1. Write. The returned version is your optimistic-concurrency token.
written = client.commit("user.preference", {"theme": "dark"})
version = written["entryVersion"]

# 2. Read.
client.recall("user preference", profile="balanced", limit=5)

# 3. Correct something you already know. Fails if it does not exist.
client.revise(
    "user.preference",
    {"theme": "light"},
    reason="user changed it in settings",
    expected_version=version,
)

# 4. Checkpoint before risky agent work.
snapshot = client.create_snapshot(label="before-autonomous-run")["snapshot"]

# 5. See what the run changed. Values are redacted by default.
client.diff(snapshot["id"])

# 6. Review what is stored and how one memory changed. Both reads are free.
client.list_memories(prefix="user.", limit=50)
client.history("user.preference")

# 7. Drop obsolete state. A reason is required and is audited.
client.forget("user.preference", reason="superseded by profile service")

# 8. Recover. Preview is free; execute is destructive and needs the token.
preview = client.rollback_preview(snapshot["id"], reason="undo bad agent run")
client.rollback(
    snapshot["id"],
    confirmation_token=preview["confirmationToken"],
    reason="undo bad agent run",
)
```

## The public surface, and what each call costs.

### commit(key, value, ...)

Write a memory. Returns an entry version for optimistic concurrency.

### recall(query, profile=, limit=)

Read memories. Profiles are entitlement gated; limit is 1–100.

### revise(key, value, reason=, expected_version=)

Replace an existing memory. Never creates.

### confirm(key, expected_version=, reason=)

Record that a memory is still accurate without resending it. 1 credit (metered as memory_write).

### forget(key, reason=, purge=False)

Destructive. Remove a memory. A reason is required. With `purge=True` its stored content is also removed from storage and history.

### list_memories(prefix=, memory_type=, updated_after=, updated_before=, cursor=, limit=50, values="preview", sources=, order=)

Free. One page of stored memories, ordered by key, or newest or oldest first with `order="newest"` / `"oldest"`. `sources=[...]` keeps memories saved by those sources. Pass nextCursor back as cursor, with the same order.

### iter_memories(prefix=, memory_type=, updated_after=, updated_before=, page_size=100, values="preview", sources=, order=)

Free. Yields every matching memory, following the cursor for you.

### history(key, limit=20, values="full")

Free. One memory’s most recent changes, newest first: 20 by default, up to 100, with truncated set when older ones exist. Values from before a forget are never returned.

### export(prefix=, memory_type=)

Free. Every matching memory with its full value, as one JSON-ready dict. History is not included.

### create_snapshot(label=) / list_snapshots(limit=)

Checkpoint the project, or list checkpoints.

### snapshot(action="create"|"list")

The same two operations behind one MCP-shaped call.

### diff(from_snapshot_id, to_snapshot_id=, include_values=)

Free comparison; values redacted by default.

### rollback_preview(snapshot_id, reason=)

Free. Returns a short-lived confirmation token.

### rollback(snapshot_id, confirmation_token=, reason=)

Destructive. Requires that token.

### status()

Authenticated workspace, plan, capabilities, limits, usage. Never billed.

### health()

Public service health.

## See what Bilinc remembers, and how it changed.

`list_memories`, `history`, and `export` only read and are never billed. The time filters take a `datetime` (a naive one is read as UTC) or an ISO-8601 string. The same commands are in the CLI: `bilinc list`, `bilinc history KEY`, `bilinc confirm KEY`, and `bilinc export -o FILE`.

Python

```
import json
import os
from bilinc import CloudClient

client = CloudClient(api_key=os.environ["BILINC_API_KEY"])

# Every memory under a prefix, page by page (free).
for entry in client.iter_memories(prefix="user."):
    print(entry["key"], entry["updatedAt"], entry.get("value"))

# How one memory changed, newest first (free).
for step in client.history("user.preference")["entries"]:
    print(step["at"], step["op"], step.get("before"), "->", step.get("after"))

# Still accurate? Confirm it without resending the value (one write).
client.confirm("user.preference", reason="user said it is still right")

# Everything, with full values, as one JSON file (free).
with open("bilinc-memory.json", "w") as handle:
    json.dump(client.export(), handle, indent=2)
```

## Use the right shape for the right state.

### working

Active short-lived context.

### episodic

Event and session memory.

### procedural

Reusable workflows.

### semantic

Durable facts and beliefs.

## Reads retry themselves; writes do not.

The SDK retries read-only calls a bounded number of times on transport and 5xx failures. Writes are single-shot on purpose: a retried write could apply twice. Pass `idempotency_key` on a write you might retry, and the server replays the original result instead of executing again.

[Error handling](https://bilinc.space/docs/errors) · [Recovery workflow](https://bilinc.space/docs/snapshots-rollback)

[Previousv2 migration](https://bilinc.space/docs/migration-v2)
[NextCLI](https://bilinc.space/docs/cli)

On this page

- Import CloudClient, then write, recall, and inspect hosted state.
- Write, correct, checkpoint, inspect, forget, recover.
- The public surface, and what each call costs.
- See what Bilinc remembers, and how it changed.
- Use the right shape for the right state.
- Reads retry themselves; writes do not.
