Skip to main content

AgentPulse SDK

Zero-config observability for AI agents. Two lines of code → full LLM call tracking with costs, latency, and traces.

Quick Start

pip install agentpulse
import agentpulse
agentpulse.init()  # That's it — all LLM calls are now tracked

import openai
client = openai.OpenAI()
resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}]
)
# → Dashboard shows: model, tokens, cost, latency — automatically

What Gets Captured

With just agentpulse.init(), the SDK automatically captures:

  • LLM calls — model, tokens, latency, cost (OpenAI, Anthropic, LiteLLM)
  • Errors — failed API calls with error details
  • Streaming — full metrics even for streamed responses
  • Cost estimates — built-in pricing for 30+ models

Structured Tracing

For richer observability, add sessions, agents, and tasks:

import agentpulse
ap = agentpulse.init()

# Group related calls into sessions
with ap.session("daily-email-check") as s:
    result = process_emails()
    s.log("Processed 5 emails")
    s.set_result("success")

# Decorate agents and tasks
@agentpulse.agent(name="email-processor")
class EmailAgent:
    @agentpulse.task(name="classify")
    def classify(self, email):
        return call_llm(email)

# Monitor cron jobs
with ap.cron("nightly-cleanup") as c:
    do_cleanup()
    # Auto-captures: start, end, duration, success/failure

Manual Events

ap.event("memory_snapshot", {"file": "MEMORY.md", "size_kb": 142})
ap.metric("queue_depth", 23)
ap.alert("Cost spike", severity="warning", details="$5.20 in last hour")

Configuration

All via init() kwargs or environment variables:

agentpulse.init(
    api_key="ap_...",              # or AGENTPULSE_API_KEY
    agent_name="my-agent",         # or AGENTPULSE_AGENT (default: hostname)
    endpoint="https://...",        # or AGENTPULSE_ENDPOINT
    enabled=True,                  # or AGENTPULSE_ENABLED (kill switch)
    capture_messages=False,        # or AGENTPULSE_CAPTURE_MESSAGES (privacy)
    auto_patch=True,               # or AGENTPULSE_AUTO_PATCH
    debug=False,                   # or AGENTPULSE_DEBUG
    flush_interval=5.0,            # seconds between flushes
    max_queue_size=10_000,         # max buffered events
)

CLI

agentpulse status   # Check config and connectivity
agentpulse test     # Send a test event
agentpulse costs    # Print the built-in cost table

Design Principles

  • Zero dependencies — stdlib only (urllib, json, threading, contextvars)
  • Never blocks — all reporting is fire-and-forget via background thread
  • <1ms overhead — just a timestamp + queue append per LLM call
  • Privacy by default — prompt/response content not captured unless opted in
  • Unpatchableshutdown() restores all original library methods

License

MIT

Release files for agentpulse-sdk 0.2.0

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

Source distribution (sdist)

Source distribution for agentpulse-sdk 0.2.0
File Size Uploaded
agentpulse_sdk-0.2.0.tar.gz 19.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentpulse-sdk 0.2.0
File Interpreter ABI Platform
agentpulse_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.3 kB

Release files / agentpulse_sdk-0.2.0.tar.gz

Download URL agentpulse_sdk-0.2.0.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6b5f82b25167527b38516f58eda7be6fe4fc40c316f6383bd63ca40855e60b1
BLAKE2b-256 checksum
How to use checksums
359a6c98a27e7307f22addf43d5484eef279a1c4be877bbda272ef755d44147f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / agentpulse_sdk-0.2.0-py3-none-any.whl

Download URL agentpulse_sdk-0.2.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb44b5d3d3259cca3d8e8362078d1dc2e42234f4941b5ffb10998a5e7b1f8972
BLAKE2b-256 checksum
How to use checksums
dd5b4902e2e3e5d452d060bcbdbe49a2c29591f17d5f3874adb9b9571370d217
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.0 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