ai-provenance-protocol — Python SDK
Official Python SDK for the AI Provenance Protocol (APP) — an open standard for recording, embedding, and verifying the provenance of AI-generated content.
Installation
pip install ai-provenance-protocol
Quick Start
from ai_provenance_protocol import APP
# 1. Create metadata after your AI call
metadata = APP.create(
generator={"platform": "my-platform", "model": "gpt-4o"},
verification_uri="https://api.example.com/v1/verify",
)
# 2. Embed it in your JSON response
output = APP.embed({"reply": "Hello, world!"}, metadata)
# output == {"reply": "Hello, world!", "_ai_provenance": {...}}
# 3. Validate it
result = APP.validate(metadata)
# result == {"valid": True, "errors": []}
API Reference
APP.create()
Creates a new APP metadata record.
metadata = APP.create(
generator={"platform": "acme-ai", "model": "acme/text-v3"},
verification_uri="https://api.acme.com/verify",
# Optional
inputs=[{"type": "prompt", "value": "Write a product description"}],
generation_id="550e8400-e29b-41d4-a716-446655440000", # auto-generated if omitted
parent_generation_id="...",
extensions={"io.acme": {"tenant_id": "t_123"}},
)
APP.embed() / APP.extract()
Embed metadata into any dict, or pull it back out.
output = APP.embed({"answer": "42"}, metadata)
content, meta = APP.extract(output)
# content == {"answer": "42"}
# meta == {...} or None if no metadata present
APP.validate()
Validate any dict against the APP v1.0 JSON Schema (bundled — no network call).
result = APP.validate(metadata)
if not result["valid"]:
for err in result["errors"]:
print(err)
APP.review()
Record a human review decision.
approved = APP.review(
metadata,
human_reviewed=True,
reviewer_role="editor",
review_type="approved_without_changes",
)
APP.hash_content()
Compute a deterministic SHA-256 hash of content (canonical JSON, sorted keys).
h = APP.hash_content({"answer": "42"})
# h == {"algorithm": "sha256", "value": "<hex>"}
metadata_with_hash = APP.attach_hash(metadata, content)
APP.verify() / APP.verify_sync()
Level 1 verification — look up a generation ID at the verification endpoint.
# Async
result = await APP.verify(
metadata["generation_id"],
metadata["verification_uri"],
)
# Sync
result = APP.verify_sync(
metadata["generation_id"],
metadata["verification_uri"],
)
# result == {"found": True, "metadata": {...}}
APP.match() / APP.match_sync()
Level 2 verification — match content by hash at the verification endpoint.
h = APP.hash_content(content)
result = APP.match_sync(h["value"], metadata["verification_uri"])
# result == {"match": True, "generation_id": "..."}
Direct imports
All functions are also importable directly from the package:
from ai_provenance_protocol import create, embed, extract, validate, review
from ai_provenance_protocol import hash_content, attach_hash, canonicalize
from ai_provenance_protocol import verify, verify_sync, match, match_sync
Type hints
Full TypedDict types are exported for use in type-checked code:
from ai_provenance_protocol import AppMetadata, Generator, ValidationResult
Live example
merchi.ai is the first conformant reference implementation. You can verify a live generation:
pip install ai-provenance-protocol httpx
python -c "
from ai_provenance_protocol import APP
result = APP.verify_sync(
'a6986899-bb06-461b-bbf7-c689cad09cbd',
'https://app.merchi.ai/api/functions/v1/verify',
)
print(result)
"
License
Apache 2.0 — see LICENSE.
Metadata
Release files for ai-provenance-protocol 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| ai_provenance_protocol-1.0.0.tar.gz | 8.2 kB | Without provenance | Details for ai_provenance_protocol-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_provenance_protocol-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for ai_provenance_protocol-1.0.0-py3-none-any.whl |
Total release size: 20.3 kB
Release files / ai_provenance_protocol-1.0.0.tar.gz
| Download URL | ai_provenance_protocol-1.0.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef77139b13f12031bdf4618acc91ed59c84a77c0666a395e149f6be6788c6e8c
|
|
BLAKE2b-256 checksum How to use checksums |
d0655355cce3938b89f36959cafdce0f581facfc7bca49d6ea65eff9f4c4dc10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / ai_provenance_protocol-1.0.0-py3-none-any.whl
| Download URL | ai_provenance_protocol-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d70046b46c32eb0461487082816f8796fe9950b945e7d3560c80fa24afcf7da
|
|
BLAKE2b-256 checksum How to use checksums |
a953e9326ce536f32e24c58b57255291368861a55144f9d41b9ca17b834af585
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for ai-provenance-protocol 1.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.