runtime-monitor-sdk
v0.1.2
Published
TypeScript/JavaScript SDK for the AI Agent Runtime Monitor — cost guardrails, hallucination detection & audit trail
Maintainers
Readme
runtime-monitor-sdk
JavaScript / TypeScript SDK for Runtime Monitor — real-time cost guardrails, kill-switches, and hallucination detection for AI agents.
Install
npm install runtime-monitor-sdkQuick start
import { AgentMonitor } from "runtime-monitor-sdk";
const monitor = new AgentMonitor({
apiKey: "am_...",
agentName: "my-agent",
budgetLimitUsd: 1.00,
});
await monitor.start();
// Track individual LLM calls manually
monitor.track({
model: "gpt-4o",
inputTokens: 1200,
outputTokens: 400,
});
await monitor.stop();Auto-wrap OpenAI client
import OpenAI from "openai";
import { AgentMonitor } from "runtime-monitor-sdk";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const monitor = new AgentMonitor({
apiKey: "am_...",
agentName: "my-agent",
budgetLimitUsd: 2.00,
});
await monitor.start();
// All calls through wrappedOpenAI are tracked automatically
const wrappedOpenAI = monitor.wrapOpenAI(openai);
const response = await wrappedOpenAI.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});
await monitor.stop();Kill-switch
monitor.onKillSwitch((reason) => {
console.error("Budget exceeded:", reason);
process.exit(1);
});Run a function with automatic session lifecycle
const result = await monitor.run(async () => {
// your agent logic here
return "done";
});API
new AgentMonitor(options)
| Option | Type | Required | Description |
|---|---|---|---|
| apiKey | string | ✅ | Your Runtime Monitor API key (am_...) |
| agentName | string | ✅ | Name displayed in the dashboard |
| budgetLimitUsd | number | — | Hard budget cap; triggers kill-switch when exceeded |
| baseUrl | string | — | Override API URL (default: https://monitor.global-soft.ro) |
| metadata | object | — | Arbitrary key/value pairs attached to the session |
Methods
| Method | Description |
|---|---|
| start() | Create a new session on the server |
| stop() | End the session and flush pending data |
| track(options) | Record a single LLM call |
| run(fn) | Start session → run fn → stop session, returns fn result |
| wrapOpenAI(client) | Returns a proxy that auto-tracks every completion call |
| onKillSwitch(cb) | Register callback invoked when the budget is exceeded |
Python SDK
pip install agent-monitorSee the main repo README for full documentation.
License
MIT
