Skip to main content

Audit & Compliance SDK for AI Agents

Project description

AgentAudit Python SDK

Official Python SDK for the AgentAudit API — audit logging and compliance monitoring for AI agents.

Installation

pip install agentaudit-client

With LangChain support:

pip install agentaudit-client[langchain]

Quick Start

from agentaudit import AgentAudit

# Initialize
audit = AgentAudit(api_key="aa_your_key_here")

# Log an agent action
audit.log(
    action="prompt_submitted",
    prompt="What is the weather?",
    response="It is sunny today.",
    metadata={"model": "gpt-4", "tokens": 150}
)

LangChain Integration

from langchain.callbacks import AgentAuditCallbackHandler
from langchain.llms import OpenAI

# Setup audit callback
audit_handler = AgentAuditCallbackHandler(
    api_key="aa_your_key_here",
    agent_id="uuid-of-your-agent"
)

# Use with any LangChain component
llm = OpenAI(callbacks=[audit_handler])
llm.predict("What is the weather?")
# Automatically logged to AgentAudit!

Features

  • Simple logging: One-line audit log submission
  • Automatic compliance: PII detection, keyword matching, rate limiting, regex matching, sentiment analysis, custom validators
  • Agent registration: Track which agents are performing actions
  • Query and export: Retrieve audit logs with filters
  • LangChain support: Drop-in callback handler
  • Type hints: Full type annotation support

Agent-to-Agent Audit Trails

Track multi-agent conversations and CrewAI workflows with distributed tracing:

import uuid
from agentaudit import AgentAudit

audit = AgentAudit(api_key="aa_your_key_here")

# Start a trace — e.g. when a CrewAI crew begins execution
trace_id = str(uuid.uuid4())

# Log the root event (crew start)
root = audit.log(
    action="crewai_crew_start",
    trace_id=trace_id,
    metadata={"crew": "Research Crew", "task_count": 3}
)

# Log child events (tasks, agent actions) with parent_span_id
audit.log(
    action="crewai_task_start",
    trace_id=trace_id,
    parent_span_id=root.id,
    prompt="Research topic X",
    metadata={"task_id": "task-1"}
)

# Query the full trace later
# (use the HTTP client or dashboard to query by traceId)

CrewAI Integration

The CrewAI observer automatically manages trace IDs and parent span IDs:

from agentaudit_crewai import AgentAuditObserver

observer = AgentAuditObserver(api_key="aa_key", crew_name="My Crew")
# trace_id is generated automatically in on_crew_start
# every event shares the same trace_id with proper parent_span_id linking

Documentation

Full API documentation: https://docs.agentaudit.io

License

MIT


Publishing (Maintainers Only)

This package is published automatically via GitHub Actions when you push a version tag:

Prerequisites

  1. Create a PyPI account
  2. Generate an API token at pypi.org/manage/account/token
  3. Add the token to your GitHub repo: Settings → Secrets and variables → Actions → New repository secret
    • Name: PYPI_API_TOKEN
    • Value: your PyPI API token (starts with pypi-)

Publish a New Version

# Update version in sdk/python/setup.py
git add sdk/python/setup.py
git commit -m "chore: bump Python SDK to v1.0.1"
git tag v1.0.1
git push origin v1.0.1

The publish-python.yml workflow will automatically build and upload to PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentaudit_client-1.0.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentaudit_client-1.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file agentaudit_client-1.0.2.tar.gz.

File metadata

  • Download URL: agentaudit_client-1.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agentaudit_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 442134d96f9e56173768a73faba0adc50cb2a5eb5b00af49700240118b8f6435
MD5 7fc6915dda8a110ae2197a4d750e5770
BLAKE2b-256 c112fe3d2dbcacf5705005b118cb86687d8e441a6b0ca6e58dba8d621d3ae4de

See more details on using hashes here.

File details

Details for the file agentaudit_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agentaudit_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c45d593c935a8bb36394045fa8adae419aa214a835437d9d5eb914242511475
MD5 f78ff6380f656b26fafeb2cadde24c09
BLAKE2b-256 40624c9121637b79f2679476742772efe8320b786c794fcb195ada61e55d0c80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page