@itsmemyan/agentwatch
v0.2.0
Published
Zero-config OpenAI usage tracking for AgentWatch — prompts never leave your server
Downloads
400
Maintainers
Readme
agentwatch
Lightweight OpenAI usage tracking for AgentWatch. Token counts, model, and latency are sent to AgentWatch after each response — prompts and completions never leave your server.
Install
npm install @itsmemyan/agentwatchUsage
import OpenAI from "openai";
import { wrap } from "@itsmemyan/agentwatch";
const openai = wrap(new OpenAI(), {
apiKey: "aw_live_...", // Your AgentWatch API key
agentId: "...", // Agent ID from your AgentWatch dashboard
});
// Use exactly as before — tracking happens automatically
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});
// Streaming works too
const stream = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
stream: true,
});
for await (const chunk of stream) { /* ... */ }What gets sent to AgentWatch
Only usage metadata — never your prompts or completions:
{
"agent_id": "...",
"model": "gpt-4o",
"prompt_tokens": 12,
"completion_tokens": 34,
"latency_ms": 843,
"success": true
}Options
| Option | Type | Description |
|--------|------|-------------|
| apiKey | string | Your AgentWatch API key (aw_live_...) |
| agentId | string | Agent ID from your dashboard |
| ingestUrl | string | Override the ingest URL (optional) |
Find your API key and agent IDs at getagentwatch.com/dashboard/integrations.
