Skip to main content

claude-monitor SDK — push traces & spans to claude-monitor from Python, wandb-style.

Project description

claude-monitor (Python)

Push traces and spans to claude-monitor from any Python script — wandb-style, zero install dependencies.

pip install claude-monitor

Quickstart

import claude_monitor as cm

cm.init(
    api_key="ba_…",          # or set CLAUDE_MONITOR_API_KEY
    project="my-bot",
    session_id="run-001",    # idempotent: same id resumes the same trace
    task_name="demo task",
    model="claude-opus-4-7",
)

cm.log_user("hello")
cm.log_assistant("hi there")
cm.log_tool_use("Read", {"file_path": "x.py"})
cm.log_tool_result("file contents")

cm.finish(outcome="good", metadata={"k": "v"})

Class-based / with

import claude_monitor as cm

with cm.Run(project="my-bot", session_id="run-002") as run:
    run.log_user("how do I install jq?")
    run.log_assistant("brew install jq")
    # implicit run.finish() on exit; on exception → outcome="bad" + error metadata

API

  • cm.init(**kwargs) -> Run — create the module-level run (wandb style).
  • cm.Run(**kwargs) — explicit run; identical kwargs.
  • cm.log_user(text), cm.log_assistant(text), cm.log_thinking(text), cm.log_tool_use(tool, input), cm.log_tool_result(text, parent_span_id=…), cm.log_attachment(name, attributes) — convenience helpers.
  • cm.log(kind=…, name=…, text=…, attributes=…, parent_span_id=…) — generic.
  • cm.finish(outcome="good"|"bad"|"neutral", metadata={…}, task_name=…, model=…).

Configuration

Argument Env var Default
api_key CLAUDE_MONITOR_API_KEY required
api_base CLAUDE_MONITOR_API_BASE hosted Railway URL
session_id random py-<uuid>
project None
scaffold "python-sdk"
machine_id derived from hostname

Span kinds

user_msg | assistant_msg | tool_use | tool_result | thinking | attachment

Common attributes the UI surfaces directly: text (string), result_text (string), tool_input (object). Anything else lands in the raw JSON view.

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

claude_monitor_sdk-0.4.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

claude_monitor_sdk-0.4.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file claude_monitor_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: claude_monitor_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for claude_monitor_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e0c02f507f1f1fcbda15bca41ea731b342edd233c9a2ba60219fbc4f26937dce
MD5 c58bb1abedd063dc2e6040185bc33c02
BLAKE2b-256 6f0d7a9ff6cb2228b276225ab4271ecf1eca5b2f045e55547a415cf8a1401a8f

See more details on using hashes here.

File details

Details for the file claude_monitor_sdk-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_monitor_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9646d80e737e98849a516d9b4c1ea47468d8826fb196915859b29f9632bb172
MD5 6d3227480b8f90cc825174d111c67991
BLAKE2b-256 f0a0e2f57052d5ad1975ff0569e175cd791f2422520943ff394d818768f1b7db

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