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.

Metadata

Release files for contextweave-sdk 0.1.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.1.0
File Size Uploaded Provenance Actions
contextweave_sdk-0.1.0.tar.gz 16.5 kB With provenance Details for contextweave_sdk-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 30.0 kB

Release files / contextweave_sdk-0.1.0.tar.gz

Download URL contextweave_sdk-0.1.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6d13f5d69dc794157198ea58d3b76dcd9fb252ebfd9ed65d86ada2efce66e993
BLAKE2b-256 checksum
How to use checksums
2ef744961f3fdf7b58286052b1bce9fd2b0d0b489e15eaf50de271d980569b0a
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 30, 2026.

Transparency log

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

Download URL contextweave_sdk-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8793cfa103462bff5ad4ebb4dfbf4ba97c34040542718b0602d821a8d71fc98
BLAKE2b-256 checksum
How to use checksums
d182738645dfca379fb8b2f48f09937523af168c75073fe27a2e7ed4525cbdc6
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 30, 2026.

Transparency log

Security for contextweave-sdk 0.1.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.1.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 30, 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.1.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