agentwatcher-sdk
v0.1.0
Published
AI API monitoring SDK — track costs, latency, and errors for OpenAI & Anthropic
Maintainers
Readme
agentwatcher-sdk
One line of code gives you full visibility into every AI API call. Track costs, monitor latency, and catch errors — powered by AgentWatcher.
Install
npm install agentwatcher-sdkQuick Start
import { AgentWatch } from "agentwatcher-sdk";
import OpenAI from "openai";
import Anthropic from "@anthropic-ai/sdk";
const aw = new AgentWatch({ apiKey: "aw_your_key_here" });
// Wrap OpenAI
const openai = aw.wrapOpenAI(new OpenAI());
// Wrap Anthropic
const anthropic = aw.wrapAnthropic(new Anthropic());
// That's it — all API calls are tracked automatically
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});What Gets Tracked
Every AI API call automatically captures:
- Model — which model was used
- Provider — openai or anthropic
- Token usage — input and output tokens
- Cost — calculated in USD based on current pricing
- Latency — end-to-end response time in ms
- Status — success or error
- Error message — if the call failed
Manual Tracking
aw.track({
model: "gpt-4o",
provider: "openai",
input_tokens: 100,
output_tokens: 50,
cost_usd: 0.00175,
latency_ms: 820,
status: "success",
});Configuration
const aw = new AgentWatch({
apiKey: "aw_your_key_here", // Required — get yours at agentwatcher.dev
endpoint: "https://...", // Optional — defaults to agentwatcher.dev
debug: true, // Optional — logs tracking activity to console
});Get Your API Key
Sign up free at agentwatcher.dev — no credit card required.
License
MIT
