Get AgentGuard Running in 5 Minutes

From zero to full agent observability in 3 lines of code. Pick your framework and copy-paste.

1. Install

AgentGuard has zero runtime dependencies. One install, nothing else to pull in.

pip install agentguard47

2. Basic Setup

Create a Tracer with an HttpSink and wrap your agent logic in a trace context. Every span, event, and cost metric flows to the dashboard automatically.

from agentguard47 import Tracer
from agentguard47.sinks.http import HttpSink

sink = HttpSink(url="https://app.agentguard47.com/api/ingest", api_key="ag_...")
tracer = Tracer(sink=sink, service="my-agent")

with tracer.trace("agent.run") as span:
    span.event("reasoning.step", data={"thought": "search docs"})
    with span.span("tool.search"):
        pass  # your tool call here

Get your API key from app.agentguard47.com → Settings → API Keys.

3. Auto-Instrument OpenAI

One call patches the OpenAI client to automatically track cost per call — token counts, model, and dollar amounts flow into every trace.

from agentguard47.instrument import patch_openai

patch_openai(tracer)  # auto-tracks cost per call

4. LangChain

AgentGuard ships a native LangChain callback handler. Pass it to any agent or chain and every LLM call, tool invocation, and chain step is traced automatically.

from agentguard47.integrations.langchain import AgentGuardHandler

handler = AgentGuardHandler(tracer=tracer)
agent.invoke({"input": "..."}, config={"callbacks": [handler]})

5. CrewAI

Wrap your crew.kickoff() call in a trace span. Tag the crew name and capture the output for full visibility into multi-agent orchestration.

with tracer.trace("crew.run") as span:
    span.set("crew.name", "research-crew")
    result = crew.kickoff()
    span.set("crew.output", str(result))

6. AutoGen

Wrap your GroupChat manager run in a trace. Capture the message count to track conversation depth and detect runaway chats.

with tracer.trace("autogen.chat") as span:
    chat_result = manager.run(message="research topic")
    span.set("autogen.messages", len(chat_result.chat_history))

7. MCP Agents

Instrument individual MCP tool calls with nested spans. Each tool invocation gets its own timing and metadata in the trace waterfall.

with tracer.trace("mcp.session") as span:
    with span.span("tool.file_read"):
        result = await session.call_tool("read_file", {"path": "data.csv"})

8. Budget Guard

Set a hard dollar cap. When your agent exceeds the budget, AgentGuard stops it automatically — no $2,000 surprise invoices.

from agentguard47 import BudgetGuard

guard = BudgetGuard(max_cost_usd=5.00)
# Agent stops automatically when budget exceeded

9. View in Dashboard

Once events are flowing, sign into the dashboard to see:

Sign Up Free View SDK on GitHub

Start your 14-day free trial

Pro-level access with 500K events/month. No credit card required.

Start Free Trial