probemetric
v2.0.10
Published
AI observability SDK for Node.js. Trace OpenAI, Anthropic, and Gemini calls with one line of code.
Downloads
96
Maintainers
Readme
probemetric
AI observability SDK for Node.js. Trace OpenAI, Anthropic, and Gemini calls with one line of code.
Install
npm install probemetricQuick Start
OpenAI
import OpenAI from "openai";
import { wrapOpenAI } from "probemetric";
const client = wrapOpenAI(new OpenAI(), { apiKey: "pm_your_api_key" });
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});Anthropic
import Anthropic from "@anthropic-ai/sdk";
import { wrapAnthropic } from "probemetric";
const client = wrapAnthropic(new Anthropic(), { apiKey: "pm_your_api_key" });
const response = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello!" }],
});Gemini
import { GoogleGenerativeAI } from "@google/generative-ai";
import { wrapGemini } from "probemetric";
const genAI = wrapGemini(new GoogleGenerativeAI(process.env.GEMINI_API_KEY!), { apiKey: "pm_your_api_key" });
const model = genAI.getGenerativeModel({ model: "gemini-2.0-flash" });
const result = await model.generateContent("Hello!");Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | required | Your ProbeMetric project key |
| redactFields | string[] | [] | Field names to redact from request/response before sending |
| disabled | boolean | false | Disable tracing (useful in tests) |
| debug | boolean | false | Log trace activity to console |
| maxRetries | number | 3 | Retry failed sends |
| retryDelay | number | 1000 | Base delay ms for exponential backoff |
| endpoint | string | auto | Custom ingest URL |
| metadata | Record<string, string> | — | Attach custom fields to all traces |
Graceful Shutdown
Traces are sent asynchronously. Call flush() before process exit to ensure all in-flight traces are delivered:
import { flush } from "probemetric";
process.on("SIGTERM", async () => {
await flush();
process.exit(0);
});Peer Dependencies
npm install openai # for wrapOpenAI
npm install @anthropic-ai/sdk # for wrapAnthropic
npm install @google/generative-ai # for wrapGeminiLicense
MIT
