Zero-Config Setup

One line to guard every agent

Drop-in integrations for CrewAI, LangChain, AutoGPT, and OpenAI. Real-time guardrails, automatic audit logging, and distributed tracing — no refactoring required.

LangChain

Callback Handler

Pass a single callback to any LangChain LLM, chain, or agent. Every prompt, response, tool call, and chain step is automatically audited with traceId propagation. Guardrails block violations before the output reaches the next link in the chain.

pip install agentaudit-client[langchain]
from agentaudit import AgentAuditCallbackHandler
from langchain_openai import ChatOpenAI

# One callback guards every LLM call + traces the full chain
handler = AgentAuditCallbackHandler(
    api_key="aa_your_key_here",
    agent_id="uuid-of-your-agent",
    guard=True
)

llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])
llm.invoke("What is the weather?")

# Query the trace after execution
print(handler.trace_id)  # "trace-uuid-123"
Guardrails enabled by default Distributed tracing auto-linked Raises ComplianceViolation on block

CrewAI

Observer

Add one observer to your Crew. Every crew start, task execution, agent action, and crew end is logged with a shared traceId and parentSpanId linking. If any task output violates a rule, the crew halts before delivery.

pip install agentaudit-client
from crewai import Crew, Agent, Task
from agentaudit_crewai import AgentAuditObserver

observer = AgentAuditObserver(
    api_key="aa_your_key_here",
    crew_name="Research Crew",
    guard=True   # Block violations automatically
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[task1, task2],
    callbacks=[observer]
)

crew.kickoff()
# Every task traced, violations blocked, full chain queryable
Guardrails enabled by default Auto traceId + parentSpanId linking Catch ComplianceViolation to handle blocks

AutoGPT

Decorator + Context Manager

Use the @guard decorator to wrap any agent function, or the AutoGPTLogger context manager for fine-grained trace control. Every thought, action, and file write is logged with full trace linking.

pip install agentaudit-client
from agentaudit import AgentAuditAutoGPT, ComplianceViolationAutoGPT

# One decorator guards your entire agent function
@AgentAuditAutoGPT.guard(api_key="aa_your_key_here", agent_name="MyAutoGPT")
def run_agent(task: str) -> str:
    return agent.run(task)

try:
    result = run_agent("Research topic X")
except ComplianceViolationAutoGPT as e:
    print(f"Blocked: {e.violations}")

# Or use the context manager for multi-step traces
logger = AgentAuditAutoGPT(
    api_key="aa_your_key_here",
    agent_name="MyAutoGPT",
    guard=True
)
with logger.trace() as t:
    t.log_action("think", prompt="Plan?", response="Research")
    t.log_action("execute", prompt="Search", response="Found 3")
Guardrails enabled by default Trace linking across all actions Decorator or context manager

REST API

Any Language

No SDK required. Send a single HTTP POST from any language, platform, or agent runtime. Useful for custom frameworks, serverless functions, or anywhere you just want raw HTTP without a dependency.

# Log a single agent action
curl -X POST https://agentaudit-api-production.up.railway.app/api/v1/audit-logs \
  -H "X-API-Key: aa_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "llm_call",
    "agentId": "uuid-of-your-agent",
    "traceId": "run-abc-123",
    "prompt": "Summarise the document.",
    "response": "The document covers Q3 financials.",
    "metadata": { "model": "gpt-4o", "tokens": 512 }
  }'

# Batch endpoint — up to 50 logs in one request
curl -X POST https://agentaudit-api-production.up.railway.app/api/v1/audit-logs/batch \
  -H "X-API-Key: aa_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{ "logs": [ { "action": "tool_use", ... }, { "action": "llm_call", ... } ] }'
import requests

AGENTAUDIT_URL = "https://agentaudit-api-production.up.railway.app/api/v1/audit-logs"
HEADERS = {
    "X-API-Key": "aa_your_key_here",
    "Content-Type": "application/json",
}

def log_action(action, prompt, response, agent_id, trace_id=None, metadata=None):
    payload = {
        "action": action,
        "agentId": agent_id,
        "prompt": prompt,
        "response": response,
    }
    if trace_id: payload["traceId"] = trace_id
    if metadata: payload["metadata"] = metadata

    r = requests.post(AGENTAUDIT_URL, json=payload, headers=HEADERS, timeout=3)
    result = r.json()
    if result.get("blocked"):
        raise Exception(f"Compliance block: {result['complianceFlags']}")
    return result
// Works in Node.js, Deno, Bun, or browser
async function logAction(payload: {
  action: string;
  agentId: string;
  prompt?: string;
  response?: string;
  traceId?: string;
  metadata?: Record<string, unknown>;
}) {
  const res = await fetch(
    'https://agentaudit-api-production.up.railway.app/api/v1/audit-logs',
    {
      method: 'POST',
      headers: {
        'X-API-Key': 'aa_your_key_here',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(payload),
    }
  );
  const data = await res.json();
  if (data.blocked) throw new Error(`Blocked: ${data.complianceFlags.join(', ')}`);
  return data;
}
Any language, any runtime Batch up to 50 logs per request Check blocked: true to enforce guardrails

OpenAI

Wrapped Client

Wrap the OpenAI client to automatically log every chat completion, completion, and embedding call. Guardrails run on outputs before they return to your code. Each call generates a traceId for downstream querying.

pip install agentaudit-client[openai]
# pip install agentaudit-client[openai]
from agentaudit import AgentAuditOpenAI, ComplianceViolationOpenAI

client = AgentAuditOpenAI(
    openai_api_key="sk-...",
    api_key="aa_your_key_here",
    agent_id="uuid-of-your-agent",
    guard=True
)

try:
    response = client.chat_completions_create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello!"}]
    )
except ComplianceViolationOpenAI as e:
    print(f"Blocked: {e.violations}")

print(client.trace_id)  # "trace-uuid-123"
// npm install agentaudit-client
import { AgentAudit } from 'agentaudit-client';

const audit = new AgentAudit({
  apiKey: 'aa_your_key_here',
  agentId: 'uuid-of-your-agent',
});

// Wrap any OpenAI call — guardrail runs on the response before it returns
const result = await audit.guardrail({
  action: 'openai_chat_end',
  prompt: 'User: Hello!',
  response: 'Assistant: Hi there.',
  metadata: { model: 'gpt-4o' },
});

if (!result.allowed) {
  throw new Error('Blocked: ' + result.violations.join(', '));
}
console.log(result.traceId); // "trace-uuid-123"
# Submit an audit log directly — no SDK needed
curl -X POST https://agentaudit-api-production.up.railway.app/api/v1/audit-logs \
  -H "X-API-Key: aa_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "openai_chat_end",
    "agentId": "uuid-of-your-agent",
    "prompt": "User: Hello!",
    "response": "Assistant: Hi there.",
    "metadata": { "model": "gpt-4o" }
  }'

# Response
# { "id": "...", "complianceFlags": [], "blocked": false, "traceId": "..." }
# If blocked: true, discard the response before delivery.
Guardrails enabled by default Chat + completion + embedding coverage Trace per API call

Choose your stack

All integrations share the same base: circuit breakers, retry with backoff, batch logging, and fail-open / fail-closed configuration. Pick the pattern that fits your codebase.

LangChain

Pass a callback handler to any LLM, chain, or agent. Automatic guardrails + trace propagation on every call.

View setup →

CrewAI

Add an observer to your Crew. All tasks, agents, and outputs traced with shared trace IDs.

View setup →

AutoGPT

Decorator for single functions, context manager for multi-step runs. Full trace linking either way.

View setup →

OpenAI

Wrap the client. Every completion and embedding call is audited and guarded automatically.

View setup →

REST API

No SDK needed. One POST from any language — Python, TypeScript, Go, Ruby, or raw cURL.

View setup →