Vercel AI SDK
Setup
The AI SDK supports tracing via OpenTelemetry. With the OpikExporter
you can collect these traces in Opik.
While telemetry is experimental (docs), you can enable it by setting experimental_telemetry
on each request that you want to trace.
To collect the traces in Opik, you need to add the OpikExporter
to your application, first you have to set your environment variables
Now you need to register this exporter via the OpenTelemetry SDK.
Next.js
Next.js has support for OpenTelemetry instrumentation on the framework level. Learn more about it in the Next.js OpenTelemetry guide.
Install dependencies:
Add OpikExporter
to your instrumentation file:
Node.js
Install dependencies:
Done! All traces that contain AI SDK spans are automatically captured in Opik.
Configuration
Pass Custom Trace name
Debugging
Use the logger level to see the more verbose logs of the exporter.