npm install @hyperdx/node-opentelemetry
const HyperDX = require("@hyperdx/node-opentelemetry");
HyperDX.init({
apiKey: "<YOUR_API_KEY>",
service: "ai-sdk",
});
const { openai } = require("@ai-sdk/openai");
const { generateObject } = require("ai");
const main = async () => {
const result = await generateObject({
model: openai("gpt-4o-mini", {
structuredOutputs: true,
}),
schemaName: "recipe",
schemaDescription: "A recipe for lasagna.",
schema: z.object({
name: z.string(),
ingredients: z.array(
z.object({
name: z.string(),
amount: z.string(),
}),
),
steps: z.array(z.string()),
}),
prompt: "Generate a lasagna recipe.",
experimental_telemetry: {
isEnabled: true,
functionId: "my-awesome-function",
metadata: {
something: "custom",
someOtherThing: "other-value",
},
},
});
// Make sure to flush the telemetry data to HyperDX
await HyperDX.shutdown();
};
You can execute the sample program by running the following command:
HYPERDX_API_KEY=<YOUR_API_KEY> npm start