Skip to main content

ContextWeave Python SDK

Typed synchronous and asynchronous clients for ContextWeave HTTP API v1. Requires Python 3.11+ and HTTPX. The 0.1 series is an API preview.

Install the published package:

python -m pip install contextweave-sdk

To develop from the repository, create a virtual environment and install the source package:

Repository tests require Node.js 24 and npm in addition to Python. On Ubuntu/Debian, install the matching virtual-environment package first if python3 -m venv reports that ensurepip is unavailable. Ubuntu 24.04 with Python 3.12 uses apt install python3.12-venv; this is a system prerequisite, not an SDK dependency.

python3 -m venv /tmp/contextweave-python-env
. /tmp/contextweave-python-env/bin/activate
python -m pip install './packages/sdk-python[dev]'
npm ci
npm run python:test
from contextweave_sdk import ContextWeave

with ContextWeave(base_url="http://127.0.0.1:2091", token="your-runtime-token") as moss:
    result = moss.recall({"query": "What is the launch color?"})
    print(result["data"]["memories"])
    print(result["meta"]["request_id"])

For asynchronous hosts:

from contextweave_sdk import AsyncContextWeave

async with AsyncContextWeave(base_url="http://127.0.0.1:2091", token="your-runtime-token") as moss:
    result = await moss.recall({"query": "What is the launch color?"})

Use the server root as base_url, without /api/v1; proxy mount paths such as https://example.test/moss/ are preserved. All methods return the original dictionary envelope, including meta.recall_status. No server or credentials are selected implicitly. Environment proxy configuration is disabled; inject a configured HTTPX transport when needed. Redirects are not followed.

Runtime methods: ingest, recall, read, evolve, bootstrap, acknowledge, change, schema. ContextWeaveAdmin and AsyncContextWeaveAdmin additionally expose reviews; initialize them separately with an admin token. Use context managers to close pooled connections, or call close() / await aclose().

Input TypedDicts live in contextweave_sdk.requests; response types live in contextweave_sdk.types. Inputs and method paths are generated from the executable server schema. CI checks drift and validates consumer types. Static types provide editor guidance; the server enforces semantic validation. Additional response keys are preserved at runtime.

Writes need a unique change_id, family_key, title, content and source evidence. Check data.status: review_required is a successful decision with no canonical write. Context-gated reads return available: False. Evolution needs the hash and timestamp of the current target, obtained through read. The SDK never fabricates source evidence or user authorization.

For confirmed delivery, request delivery_mode: "confirmed", inject selected memories into model context, then acknowledge their IDs and receipt. A response with no memories may have no delivery receipt. Reads and unsuccessful injection attempts do not imply delivery.

ApiError exposes status, code, request_id and optional validation issues. TransportError.code distinguishes network, timeout and invalid_response. No automatic retries are performed. Retrying an applied intent uses its unchanged change_id; pending reviews are reconsiderable rather than immutable applied receipts. Async cancellation propagates as the standard asyncio.CancelledError.

The constructor and each method accept timeout in seconds. This uses HTTPX's connect/read/write/pool inactivity timeouts, not a total wall-clock deadline. Async hosts can use asyncio.timeout(seconds) around an operation for a total deadline. Synchronous calls can time out but have no separate cancellation handle.

After installation, run the synthetic example against an isolated backend:

MOSS_BASE_URL=http://127.0.0.1:2091 MOSS_RUNTIME_TOKEN=your-runtime-token python examples/python/run.py

Each example run deliberately saves one synthetic record. Tests start a temporary backend and remove its database afterward; paid model routes are disabled. Build an sdist and wheel with python -m build packages/sdk-python. For testing in another project, install the wheel from packages/sdk-python/dist/. Registry releases are built, tested and published through the repository's protected PyPI environment.

Recall receipts

On upgraded backends ordinary recall returns data["receipt"], including empty recalls. ContextWeaveAdmin.receipt({"receipt_id": ...}) reads owner-only details; the async admin client supports the same operation. Keep receipt data outside model context. acknowledge accepts optional memory_package_tokens from the host. See receipt contract.

Metadata

Release files for contextweave-sdk 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextweave-sdk 0.2.0
File Size Uploaded Provenance Actions
contextweave_sdk-0.2.0.tar.gz 17.2 kB With provenance Details for contextweave_sdk-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for contextweave-sdk 0.2.0
File Interpreter ABI Platform Actions
contextweave_sdk-0.2.0-py3-none-any.whl Python 3 none any Details for contextweave_sdk-0.2.0-py3-none-any.whl

Total release size: 31.1 kB

Release files / contextweave_sdk-0.2.0.tar.gz

Download URL contextweave_sdk-0.2.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d4dc0a90982c0ff78c23ea861066d3ada8525a8096eafe4b366b80e0a126be6e
BLAKE2b-256 checksum
How to use checksums
c328b3ebaf8a990712f8ec91d5cd2ef91a41ac4a2b9a9ac4ce79d26c3dcd55d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / contextweave_sdk-0.2.0-py3-none-any.whl

Download URL contextweave_sdk-0.2.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e25ecfdba450344454443a7703efd1a4a089491eff2344c7dd4045e2aada07dc
BLAKE2b-256 checksum
How to use checksums
513d47369a726625d0be2c22e52580ee8c5902647e121b407794288182f2cdff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for contextweave-sdk 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for contextweave_sdk-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page