← Back to changelog
August 2, 2024

Vercel AI SDK Integration

Picture Hassieb PakzadHassieb 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:

Vercel AI SDK Example Trace in Langfuse

See docs to get started.

Was this page useful?

Questions? We're here to help

Subscribe to updates