Vercel AI SDK
Vercel AI SDK is a great library 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:
- By default, Laminar will track all OpenTelemetry traces. To prevent tracking all API calls, set the following environment variable:
Enable Vercel AI SDK tracing
Enable experimental_telemetry
in the Vercel AI SDK configuration.
NextJS
NextJS route handler example:
Results
And that’s it! You should now see traces in Laminar.