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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_monitor_sdk-0.3.0.tar.gz.
File metadata
- Download URL: claude_monitor_sdk-0.3.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acf4f11b3b82c2498624fcc59456c6ada66961dd2aeca891309f998f40868c50
|
|
| MD5 |
216842d4bdcb215daed45c9a5ac4325d
|
|
| BLAKE2b-256 |
fa4c74833db87943d4da95236f73191af94d3dfac4bcd8eb9ae558206328383a
|
File details
Details for the file claude_monitor_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: claude_monitor_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed1ad9f54052404e81cd2549c18ec7bd657000db559ddc5f6b28f72ead229ee
|
|
| MD5 |
3b8d1d4df889ea2377ae21aedf2b44c5
|
|
| BLAKE2b-256 |
eca4ebb41f92dcce4d92c47d88205b4fb171c829ed9c5d75d59cced12d3c2417
|