Vercel AI SDK
Vercel AI SDK is a library that allows you to add LLM features to your JS/TS applications. It supports tracing using OpenTelemetry.
Laminar tracing is based on OpenTelemetry, so it is fully compatible with Vercel AI SDK tracing and you can start sending Vercel AI SDK traces to Laminar right away.
This guide will show you how to send Vercel AI SDK traces to Laminar if you are using NextJS app router.
Initialize Laminar
-
Add
instrumentation.ts
to the root of your NextJS project. Learn more aboutinstrumentation.ts
here. -
Inside of
instrumentation.ts
, initialize Laminar with your project API key as follows:
Enable Vercel AI SDK tracing
Enable experimental_telemetry
in the Vercel AI SDK configuration.
NextJS
NextJS route handler example:
Laminar skips saving thorough traces created by Next.js by default and only keeps AI SDK traces. Learn more about tracing in Next.js.
Results
And that’s it! You should now see traces in Laminar.