Python SDK for QuantaWatch — AI agent security gateway
Project description
QuantaWatch Python SDK
Python SDK for QuantaWatch — the post-quantum security layer for AI agents.
Route your AI SDK traffic through the QuantaWatch gateway for threat detection, policy enforcement, and tamper-evident audit logging — all signed with post-quantum cryptography (ML-DSA-65).
Installation
Not yet published to PyPI. Install from source until the first release.
git clone https://github.com/dyber-pqc/QuantaWatch.git
pip install -e QuantaWatch/sdk/python
Requirements: Python 3.10+
Quick Start
Option 1: Protect an existing AI client (recommended)
The protect() wrapper transparently routes your existing SDK's HTTP traffic through the gateway. No code changes needed beyond the wrap call.
from anthropic import Anthropic
from quantawatch import protect
# One line — all API calls now flow through QuantaWatch
client = protect(Anthropic(), gateway_url="http://localhost:9090")
# Use the client exactly as before
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
Works with any httpx-based SDK, including OpenAI:
from openai import OpenAI
from quantawatch import protect
client = protect(OpenAI(), gateway_url="http://localhost:9090")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
Option 2: Use the gateway client directly
The QuantaWatchClient gives you direct access to the gateway proxy and admin API.
import asyncio
from quantawatch import QuantaWatchClient
async def main():
async with QuantaWatchClient() as qw:
# Proxy a raw request through the gateway
response = await qw.proxy_request(
"POST",
"/v1/messages",
headers={
"x-api-key": "sk-ant-...",
"anthropic-version": "2023-06-01",
"Content-Type": "application/json",
},
body=b'{"model":"claude-sonnet-4-20250514","max_tokens":1024,"messages":[{"role":"user","content":"Hello!"}]}',
)
print(response.status_code, response.text)
# Query the admin API
sessions = await qw.get_sessions()
stats = await qw.get_stats()
audit = await qw.get_audit_entries(limit=10)
# Verify audit chain integrity
result = await qw.verify_audit_chain()
print("Audit chain valid:", result.get("valid"))
asyncio.run(main())
API Reference
protect(client, *, gateway_url="http://localhost:9090")
Wraps an AI SDK client so its HTTP traffic flows through the QuantaWatch gateway.
| Parameter | Type | Default | Description |
|---|---|---|---|
client |
Any |
— | An AI SDK client (Anthropic, OpenAI, or any httpx-based client) |
gateway_url |
str |
http://localhost:9090 |
URL of the QuantaWatch gateway |
Returns a proxy object that behaves identically to the original client.
QuantaWatchClient
Async client for the QuantaWatch gateway and admin APIs.
QuantaWatchClient(
gateway_url="http://localhost:9090",
admin_url="http://localhost:9091",
timeout=30.0,
)
| Method | Description |
|---|---|
proxy_request(method, path, headers, body) |
Proxy an HTTP request through the gateway |
get_sessions() |
List all gateway sessions |
get_audit_entries(limit=100) |
Fetch recent audit log entries |
get_stats() |
Fetch aggregate gateway statistics |
verify_audit_chain() |
Verify cryptographic audit chain integrity |
close() |
Close the underlying HTTP client |
Types
All response types are Pydantic models:
SessionInfo— Gateway session with agent name, token count, PQC key fingerprintAuditEntry— Signed audit log entry with sequence number and hash chainGatewayStats— Aggregate stats (sessions, requests, threats, audit entries)ThreatAssessment— Threat analysis result with severity and blocked statusDetectedThreat— Individual threat with category, severity, confidence, and pattern name
Prerequisites
The SDK requires a running QuantaWatch gateway. Start one with Docker:
git clone https://github.com/dyber-pqc/QuantaWatch.git
cd QuantaWatch
cp quantawatch.yaml.example quantawatch.yaml
export ANTHROPIC_API_KEY=sk-ant-...
docker compose up -d
Or build from source:
cargo run -p qw-gateway -- quantawatch.yaml
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking (if mypy installed)
mypy quantawatch/
License
Links
Project details
Release history Release notifications | RSS feed
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 quantawatch-0.1.3.tar.gz.
File metadata
- Download URL: quantawatch-0.1.3.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4957a149ba1c6e16b3883e0a8da0fa88ec0274080413061728f97c4405bd38c5
|
|
| MD5 |
11449b76882b5659d24609c1f3eb6e68
|
|
| BLAKE2b-256 |
e27e8fd34c0191bf3be89cbdfc59f194d04c95972bc3b1bc9a92caa090c26d9a
|
Provenance
The following attestation bundles were made for quantawatch-0.1.3.tar.gz:
Publisher:
release.yml on dyber-pqc/QuantaWatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantawatch-0.1.3.tar.gz -
Subject digest:
4957a149ba1c6e16b3883e0a8da0fa88ec0274080413061728f97c4405bd38c5 - Sigstore transparency entry: 2249997224
- Sigstore integration time:
-
Permalink:
dyber-pqc/QuantaWatch@da3678c71f96e4f13feb24c2678b5d74beace642 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dyber-pqc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da3678c71f96e4f13feb24c2678b5d74beace642 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quantawatch-0.1.3-py3-none-any.whl.
File metadata
- Download URL: quantawatch-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
559382b5392f2f27ef56fd5d53fa100fd80f80a4631337d4e881aa5656471d0b
|
|
| MD5 |
0409e45b76560ac431f803362de40071
|
|
| BLAKE2b-256 |
c9b6aba97a8e55a64283ca8207ebd82813b06a933cebc5849032fd4656e46235
|
Provenance
The following attestation bundles were made for quantawatch-0.1.3-py3-none-any.whl:
Publisher:
release.yml on dyber-pqc/QuantaWatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantawatch-0.1.3-py3-none-any.whl -
Subject digest:
559382b5392f2f27ef56fd5d53fa100fd80f80a4631337d4e881aa5656471d0b - Sigstore transparency entry: 2249997311
- Sigstore integration time:
-
Permalink:
dyber-pqc/QuantaWatch@da3678c71f96e4f13feb24c2678b5d74beace642 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/dyber-pqc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da3678c71f96e4f13feb24c2678b5d74beace642 -
Trigger Event:
push
-
Statement type: