← Back to changelog
August 2, 2024
Vercel AI SDK Integration
Hassieb Pakzad
The AI SDK now supports OpenTelemetry-based instrumentation. With the new LangfuseExporter, you can easily collect these traces in Langfuse.
instrumentation.ts
import { registerOTel } from "@vercel/otel";
import { LangfuseExporter } from "langfuse-vercel";
export function register() {
registerOTel({
serviceName: "langfuse-vercel-ai-example",
traceExporter: new LangfuseExporter(),
});
}
const result = await generateText({
model: openai("gpt-4-turbo"),
prompt: "Write a short story about a cat.",
experimental_telemetry: { isEnabled: true },
});
Example Trace:
See docs to get started.