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.5.0.tar.gz (19.0 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.5.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: claude_monitor_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 19.0 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.5.0.tar.gz
Algorithm Hash digest
SHA256 851e1c75c8ef7623b0bd2018e3d194c15b4ee32edce958b76ee9eb3acdf328c1
MD5 1e454c457fef11dde408e99e7fe8ab26
BLAKE2b-256 4c3eaf25280d8e400e001045c5aac2eabfd0074b465727ce0bcc05d123d61277

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for claude_monitor_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fee017842ced56299f29da51476e4d50e15c0a0467c40c752f2b4e166865a485
MD5 1851b004df1865e4ebf0fcc080c9234d
BLAKE2b-256 102fa0a852303b7773c4fd1ecfc693d9fac879b35ee0b89b84350839e8904c0d

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