AI Cognitive Evidence Platform — EU AI Act compliance with blockchain proof
Project description
proofai
Cryptographic proof that AI thought before it answered.
EU AI Act compliance with blockchain anchoring on Polygon PoS mainnet.
Install
pip install proofai
Quick Start
from proofai import ProofAI
client = ProofAI(api_key="pk_live_...")
cert = client.certify("Analyse the legal risks of this SaaS contract")
print(cert.verified) # True
print(cert.bundle_id) # bnd_8019b37a7f44_...
print(cert.bundle_hash) # sha256 hash
print(cert.explorer_url) # https://polygonscan.com/tx/0x...
print(cert.trace_quality) # "inferred_via_gemini"
print(cert.cognitive_nodes) # 7
Environment variables
export PROOFAI_ANON_KEY="pk_live_..."
from proofai import certify, verify, log
# One-shot certification
cert = certify("Analyse the legal risks of this SaaS contract")
# Verify an existing bundle
result = verify("bnd_8019b37a7f44_...")
print(result.verified) # True
# Audit log a decision (no blockchain anchoring)
bundle = log("Loan application auto-rejected", {"subject": "user_123"})
print(bundle.id)
Context manager
from proofai import ProofAI, CertifyOptions
with ProofAI(api_key="pk_live_...") as client:
cert = client.certify(
"Summarise the GDPR implications of this data sharing agreement",
CertifyOptions(provider="anthropic"),
)
assert cert.verified
Cognitive Analysis — Two-tier System
ProofAI captures real AI reasoning as evidence, not just the final output.
Tier 1 — Native (Gemini provider only)
When provider="gemini", ProofAI calls gemini-2.0-flash-thinking-exp-1219 and
extracts real thought: true blocks. Each thinking segment becomes a cognitive
node with its actual content and SHA-256 hash. trace_quality = "native".
Tier 2 — Inferred (Claude, GPT, all others)
When provider="anthropic" or "openai", ProofAI calls the provider for the
response, then calls Gemini Thinking to reconstruct the reasoning chain that most
likely produced it. trace_quality = "inferred_via_gemini". A disclaimer field
is set noting the trace is inferred.
Fallback
If GOOGLE_AI_API_KEY is not configured server-side, a single SHA-256 hash of the
output is recorded. trace_quality = "output_hash".
cert = client.certify("Your prompt", CertifyOptions(provider="gemini"))
# Access individual cognitive nodes
for node in cert.steps.analyze.nodes:
print(node.label) # First sentence of the reasoning step
print(node.hash) # SHA-256 of the node content
print(node.trace_source) # "native_thinking" | "inferred_via_gemini"
Step-by-Step Pipeline
from proofai import ProofAI
client = ProofAI(api_key="pk_live_...")
# 1. Compress prompt to canonical DSL
compressed = client.compress("Your prompt here", compression_level="medium")
# 2. Execute AI (captures reasoning_trace + trace_quality)
execution = client.execute(
compressed.id,
provider="anthropic",
temperature=0.7,
max_tokens=1024,
)
# 3. Cognitive analysis — pass the real thinking trace
analysis = client.analyze(
execution.id,
execution.output,
execution.reasoning_trace,
execution.trace_quality,
)
# 4. Sign with Ed25519
signature = client.sign(execution)
# 5. Create evidence bundle
bundle = client.bundle(
compressed.id,
execution.id,
analysis.id,
signature.signature_id,
analysis.cognitive_hash,
)
# 6. Anchor to Polygon PoS mainnet
anchor = client.anchor(bundle.id, network="polygon")
print(anchor.explorer_url) # https://polygonscan.com/tx/0x...
# 7. Verify
verification = client.verify(bundle.id)
print(verification.verified) # True
certify() Options
| Option | Type | Default | Description |
|---|---|---|---|
provider |
"anthropic" | "openai" | "gemini" |
"anthropic" |
AI provider |
model_id |
str |
auto | Model override |
temperature |
float |
0.7 |
Generation temperature |
max_tokens |
int |
1024 |
Max output tokens |
compression_level |
"low" | "medium" | "high" |
"medium" |
DSL compression level |
network |
"polygon" | "ethereum" |
"polygon" |
Blockchain network |
skip_anchor |
bool |
False |
Skip blockchain anchoring |
from proofai import ProofAI, CertifyOptions
cert = client.certify(
"Your prompt",
CertifyOptions(
provider="gemini",
temperature=0.5,
max_tokens=2048,
network="polygon",
),
)
Human Review (EU AI Act Art. 14)
review = client.review(
bundle_id=cert.bundle_id,
reviewer_id="officer@example.com",
role="compliance_officer",
decision="approved",
notes="Reviewed and approved for production use.",
)
print(review.decision) # "approved"
Monitoring
stats = client.monitor()
print(stats.total_executions)
print(stats.anomaly_count)
print(stats.compliance)
Self-Hosted
client = ProofAI(
api_key="your-supabase-anon-key",
base_url="https://your-project.supabase.co/functions/v1",
)
License
MIT
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 proofai-1.0.0.tar.gz.
File metadata
- Download URL: proofai-1.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
864b3aa18e1f4eb5a41b58ce80d070a5aa6495c8643526cabb0d32a4290ced3a
|
|
| MD5 |
3f0abf9b584aaa1eac2e286cc37578f8
|
|
| BLAKE2b-256 |
14d646b5ed01f6aed02c8159ef8199a817b6ad3cbf2eec18b726eb21ac8eb1de
|
File details
Details for the file proofai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: proofai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c437202f4c7b3f946724c419598f83256af15f092e5b9413776d654984abb5c2
|
|
| MD5 |
5087cec723bbff608628610021ad2afc
|
|
| BLAKE2b-256 |
9119c2f3585e40cecb333c2a4230d50a67cb4d8c14f2ca766baba108fa99644e
|