witness-ai 0.2.0
Compliance-grade AI audit trail with conversation tracking. We never see your data.
Requires Python: >=3.9
Keywords: ai audit trail gdpr compliance governance receipts

# witness-ai

**The audit trail that never saw your data.**

Compliance-grade AI audit trail with physics timestamps. One line of code. We never see your data.

## Install

```bash
pip install witness-ai
```

## Quick Start

```python
from witness_ai import Witness

w = Witness(api_key="wai_...")

# Option 1: Wrap any AI function call
response = w.wrap(openai.chat.completions.create)(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello"}]
)

# Option 2: Wrap an OpenAI client (all calls receipted automatically)
from openai import OpenAI
client = w.openai(OpenAI())
response = client.chat.completions.create(model="gpt-4", messages=...)

# Option 3: Wrap an Anthropic client
from anthropic import Anthropic
client = w.anthropic(Anthropic())
response = client.messages.create(model="claude-3-opus-20240229", ...)

# Check your receipt
print(w.last_receipt)
# → WitnessReceipt(receipt_id='wr_...', chain_position=42, physics_quality='FULL', ...)
```

## How It Works

1. **SDK hashes your request locally** (SHA-256) — your data never leaves your machine
2. **SDK sends only the hash** to the Witness API — we never see your data
3. **Witness API generates a receipt** — physics-timestamped, hash-chained, tamper-evident
4. **SDK returns the original AI response** — unchanged, plus the receipt

## What You Get

- **Immutable audit trail** — hash-chained receipts, tamper-evident
- **Physics timestamps** — Verifiable Delay Function, not NTP (unspoofable)
- **GDPR compliance** — we never see your data (only hashes)
- **Compliance exports** — JSON/PDF for auditors, regulators, lawyers
- **1-line integration** — wrap existing code, zero changes to your AI

## Conversation Tracking

Every turn in a multi-turn conversation is automatically tracked with a `conversation_id` and `turn_number`.

```python
from witness_ai import Witness
from anthropic import Anthropic

witness = Witness(
    api_key="wai_...",
    labels={"department": "lending", "employee": "marie.laurent"}
)
client = witness.anthropic(Anthropic())

messages = []
with witness.conversation() as conv_id:
    # Turn 1
    messages.append({"role": "user", "content": "Should we approve this mortgage?"})
    r = client.messages.create(model="claude-3-haiku-20240307", max_tokens=200, messages=messages)
    messages.append({"role": "assistant", "content": r.content[0].text})

    # Turn 2 — same conversation_id, turn_number=2
    messages.append({"role": "user", "content": "What if there's also a car loan?"})
    r = client.messages.create(model="claude-3-haiku-20240307", max_tokens=200, messages=messages)

# A judge can query: "Show me all receipts from conversation conv_id"
# Result: 2 turns, department=lending, employee=marie.laurent, timestamped, signed.
```

Auto-detection also works without the context manager — the SDK groups receipts by the hash of the first message.

## Compliance Export

```python
# Export your complete chain for auditors
export = w.export()
# → JSON with all receipts, chain integrity proof, physics timestamps,
#   and a compliance statement certifying zero data exposure.
```

## Verify Chain Integrity

```python
# Prove your chain hasn't been tampered with
verification = w.verify_chain()
print(verification)
# → {"chain_valid": true, "chain_length": 4291, ...}
```

## Pricing

- **Unlimited**: €5,000/month (enterprise compliance)

## Why Witness?

| | Helicone | LangSmith | Braintrust | **Witness** |
|---|---|---|---|---|
| **Sees your data?** | Yes | Yes | Yes | **No** |
| **GDPR safe?** | DPA needed | DPA needed | DPA needed | **By architecture** |
| **Tamper-proof?** | No | No | No | **Yes (hash chain)** |
| **Physics timestamp?** | No | No | No | **Yes (VDF)** |

---

Built on [Recognitium](https://recognitium.com) physics-proof technology.