With our SDKs, tracking OpenAI calls is super simple.
Copy
import OpenAI from "openai";import { monitorOpenAI } from "lunary/openai";// Simply call monitor() on the OpenAIApi class to automatically track requestsconst openai = monitorOpenAI(new OpenAI());
3
Tag requests and identify users
You can now tag requests and identify users.
Copy
const result = await openai.chat.completions.create({ model: "gpt-4o", temperature: 0.9, tags: ["chat", "support"], // Optional: tags user: "user_123", // Optional: user ID userProps: { name: "John Doe" }, // Optional: user properties messages: [ { role: "system", content: "You are an helpful assistant" }, { role: "user", content: "Hello friend" }, ],});