Skip to main content

counteraudit

Python client for the CounterAudit API. Requires Python 3.8+.

Install

pip install counteraudit

Usage

import os
from counteraudit import CounterAuditClient, CounterAuditError

# Initialize client
client = CounterAuditClient(
    base_url="https://api.counteraudit.io",
    api_key=os.environ["COUNTERAUDIT_API_KEY"],
    timeout=30,      # optional (seconds)
    max_retries=2    # optional (transient 429/5xx retry budget)
)

# Health check
print(client.health())
# {'ok': True, 'service': 'counteraudit-api', 'version': '0.8.0'}

# Ingest an event
result = client.ingest(
    connector_id="langchain-v0.3",
    raw_event={
        "run_id": "run-1",
        "model_id": "gpt-4o",
        "input": "hello"
    }
)
print(result["packet_id"], result["entry_hash"])

# Verify a packet
verification = client.verify(result["packet_id"])
print(verification["valid"])  # True
print(verification["rfc3161_verified"])

# Get agentic debt metrics
debt = client.dashboard_debt(days=30)
print(debt["agentic_debt_index"])
print(debt["by_connector"])

# List packets (paginated)
page = client.list_packets(limit=20)
print(len(page["packets"]))
if page["next_cursor"]:
    next_page = client.list_packets(cursor=page["next_cursor"])

# Proof-first wrappers (v1 naming)
record = client.proof.record(
    connector_id="langchain-v0.3",
    raw_event={"run_id": "run-2", "model_id": "gpt-4o", "input": "proof wrapper"}
)
verified = client.proof.verify(record["packet_id"])
chain = client.proof.chain_verify(org_id=os.environ.get("COUNTERAUDIT_ORG_ID", "00000000-0000-4000-8000-000000000001"))
exported = client.proof.export(limit=10)
print(verified["valid"], chain["valid"], exported["count"])

Context manager

with CounterAuditClient(base_url="...", api_key="...") as client:
    health = client.health()
    print(health)
# Session automatically closed

Error handling

try:
    client.verify("invalid-packet-id")
except CounterAuditError as e:
    print(f"Error {e.status_code}: {e.message}")
    print(f"Code: {e.error_code}, Request-ID: {e.request_id}")
    print(e.body)  # Full error response

Reliability behavior

  • configurable request timeout (timeout)
  • transient retry policy (max_retries) on 429/5xx
  • richer error fields on CounterAuditError:
    • status_code
    • error_code
    • request_id
    • body

API Reference

Method Maps to Returns
health() GET /health Health dict
ingest(connector_id, raw_event, org_id=None) POST /v1/audit/ingest Ingest result
verify(packet_id) GET /v1/audit/verify/:id Verification result
chain(org_id) GET /v1/audit/chain/:org_id Chain summary
list_packets(limit=None, cursor=None) GET /v1/audit/packets Paginated list
proof.record(connector_id, raw_event, org_id=None) POST /v1/audit/ingest Ingest result
proof.verify(packet_id) GET /v1/audit/verify/:id Verification result
proof.chain_verify(org_id) GET /v1/audit/chain/:org_id Chain summary
proof.export(limit=None, cursor=None) GET /v1/audit/packets Paginated list
list_connectors() GET /v1/connectors Connectors list
register_connector(...) POST /v1/connectors/register Created connector
update_connector(id, field_map=None, risk_defaults=None) PATCH /v1/connectors/:id Updated connector
delete_connector(connector_id) DELETE /v1/connectors/:id None
list_keys() GET /v1/keys Keys list (masked)
create_key(label=None) POST /v1/keys Created key (plaintext once)
delete_key(key_id) DELETE /v1/keys/:id None
dashboard_debt(days=None) GET /v1/dashboard/debt Debt summary

Development

From the monorepo:

cd packages/counteraudit-py
pip install -e .

License

MIT — see LICENSE in the repository root.

Metadata

Release files for counteraudit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for counteraudit 0.1.1
File Size Uploaded
counteraudit-0.1.1.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for counteraudit 0.1.1
File Interpreter ABI Platform
counteraudit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / counteraudit-0.1.1.tar.gz

Download URL counteraudit-0.1.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
53496f8f54900055399d0006de17e795d8a35379cb67d8fe195b862221d5f6d1
BLAKE2b-256 checksum
How to use checksums
0249f7f0bd27f8e256da0efdb4ba024e7ccf6445dabe0790925fdf0c3d73a5ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / counteraudit-0.1.1-py3-none-any.whl

Download URL counteraudit-0.1.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48e7840a97e981e55fd803418d8e80e9945f08f4b0945ccaf93740e53b0bbd9b
BLAKE2b-256 checksum
How to use checksums
f410046ada274cf657f36a60d158ba16819a59431adcc8ebe520a9a5280d2f6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page