vaxelia-ai-anthropic
A drop-in, compliance-instrumented wrapper around the official
Anthropic Python SDK. Every non-streaming
messages.create call is logged to your tenant's decision-log endpoint via
vaxelia-ai-core — with its resilient,
encrypted-on-disk buffer — so an AI decision is never silently lost. Every other
method of the Anthropic SDK passes straight through to the real client untouched.
anthropic is a regular dependency of this package, so the wrapper is a true
single-install drop-in: you do not install the Anthropic SDK separately.
Install
pip install vaxelia-ai-anthropic
Requires Python >= 3.9.
The one-line swap
Change your import — keep everything else:
- from anthropic import Anthropic
+ from vaxelia_ai_anthropic import Anthropic
Usage
import os
from vaxelia_ai_anthropic import Anthropic
client = Anthropic(
api_key=os.environ["ANTHROPIC_API_KEY"],
# Optional compliance block. Every field falls back to an env var (below),
# so you can also pass nothing here and configure entirely from the env.
compliance={
"ai_system_id": os.environ.get("VAXELIA_AI_SYSTEM_ID"),
"tenant_api_url": os.environ.get("VAXELIA_TENANT_API_URL"),
"api_key": os.environ.get("VAXELIA_API_KEY"),
"buffer_key": os.environ.get("VAXELIA_BUFFER_KEY"),
},
)
# Identical to the official SDK. The decision is logged for you.
message = client.messages.create(
model="claude-3-5-sonnet-latest",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize the attached contract."}],
)
With env vars set, the compliance block can be omitted entirely:
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
The compliance argument accepts either a vaxelia_ai_core.ReporterConfig or a
plain dict with the same field names.
Reaching the raw client
For methods this wrapper does not instrument, the underlying Anthropic client is
available at client.raw, and every other attribute/method (models, beta,
with_options, …) delegates to the real client automatically. On the messages
resource, every method other than create (stream, count_tokens,
batches, …) delegates directly to the real resource.
Configuration & environment variables
The compliance block is a ReporterConfig from vaxelia-ai-core. Every field
is optional and falls back to a matching environment variable (12-factor):
compliance field |
Environment variable | Description |
|---|---|---|
ai_system_id |
VAXELIA_AI_SYSTEM_ID |
Registered AI system identifier. |
tenant_api_url |
VAXELIA_TENANT_API_URL |
Full decision-log POST endpoint URL. |
api_key |
VAXELIA_API_KEY |
Bearer token for the tenant API. |
buffer_key |
VAXELIA_BUFFER_KEY |
32-byte AES-256-GCM key, base64-encoded. Required to buffer. |
For the encrypted disk buffer, the fail-closed buffer-key rule, retention, and
backoff behaviour, see the
vaxelia-ai-core README. Note: when buffering is
enabled (the default) and no valid 32-byte buffer key is resolvable,
construction raises (MissingBufferKeyError / InvalidBufferKeyError) —
this wrapper surfaces that error rather than swallow it. To run without a disk
buffer, set compliance.buffering_enabled = False.
What gets logged
On each instrumented messages.create call, one decision envelope is reported:
| Field | Source |
|---|---|
aiSystemId |
compliance.ai_system_id / VAXELIA_AI_SYSTEM_ID |
modelUsed |
the response's model, falling back to the request model |
input |
the messages.create request kwargs |
output |
the provider response (via model_dump()), or on failure {"error": ...} |
status |
completed on success, failed when the provider call raises |
decidedAt |
ISO-8601 timestamp at the moment of the call |
Reporter-error ordering (no silent drops)
The provider response is always obtained first; only then is the decision
logged. If vaxelia-ai-core cannot deliver the decision and cannot durably
buffer it, it raises (DecisionNotRecordedError) — and this wrapper lets that
error surface to your caller. This is deliberate: the whole point of the
compliance layer is that a recorded decision is never silently dropped. If you
prefer delivery failures to be buffered instead of raised, keep buffering enabled
(the default) with a valid buffer key — transient failures (network, 5xx, 429)
are then retried with backoff and buffered to encrypted disk for later flush.
On a failed provider call, the failed decision is reported first (capturing
only the error message, never the raw exception, which may carry request bodies
or credentials), and then the original provider exception is re-raised unchanged.
Scope & limitations
- Streaming is not instrumented in v1. A call with
stream=Truepasses straight through to the real client uninstrumented, so streaming usage never breaks — but no decision is logged for it yet. Streaming compliance capture is a planned enhancement. - Only
messages.createis instrumented. All other SDK methods delegate to the real client; reachclient.rawfor the underlying object when needed.
Development
# From sdks/python, with the shared venv:
.venv/bin/pip install -e vaxelia-ai-core
.venv/bin/pip install -e vaxelia-ai-anthropic
.venv/bin/python -m pytest vaxelia-ai-anthropic
Metadata
Release files for vaxelia-ai-anthropic 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vaxelia_ai_anthropic-0.1.0.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vaxelia_ai_anthropic-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / vaxelia_ai_anthropic-0.1.0.tar.gz
| Download URL | vaxelia_ai_anthropic-0.1.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a31541a5164aee88e00359a9433ac072c854581edf33e6c91524cfe6f7ea46bf
|
|
BLAKE2b-256 checksum How to use checksums |
c7143e536d4148175c5d6da23b172c6fd0da3092fd11e3ff3514b20df9751fea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / vaxelia_ai_anthropic-0.1.0-py3-none-any.whl
| Download URL | vaxelia_ai_anthropic-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25d788c32a3be9cd498facd7a987080a6b93e8b2219a8d4be44d7c2e90451710
|
|
BLAKE2b-256 checksum How to use checksums |
47f4c77c447bb108034fa6fe51135c2f25ead8e463133fea7fff777801d7ddcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|