HTTP client for the CounterAudit audit ingest API
Project description
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"]
)
# 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"])
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(e.body) # Full error response
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 |
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.
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
counteraudit-0.1.0.tar.gz
(6.5 kB
view details)
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 counteraudit-0.1.0.tar.gz.
File metadata
- Download URL: counteraudit-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19f46f8981039029bc72259b126d5c468d532571ffb23ce5342bd6b4b9c8546a
|
|
| MD5 |
0bccca3bdae06b70469157da546de5d0
|
|
| BLAKE2b-256 |
a7953dcaef25b532f9ff24459e59ef8fdf57991500e5b48947c395952a0cf8c3
|
File details
Details for the file counteraudit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: counteraudit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4b7b6b36c1ea4fd39186607d88ca8c09b59cd9005b5677915728f629b89e953
|
|
| MD5 |
2d22984806f064ce9af644ac071e67b5
|
|
| BLAKE2b-256 |
31b7021ca65baf6dfba47710a236a307a9cd0c6a7b16b9f1869369f85c407de5
|