This guide explains how to integrate HoneyHive with the Vercel AI SDK for TypeScript implementations.
sessionId
and pass it to your AI SDK call to link multiple AI SDK requests to the same user session.instrumentation.ts
(or .js) file in the root directory of the project (or inside src
folder if using one) and paste the following code:
Note that the serviceName
need not be the same as your HoneyHive project name.
next.config.mjs
or next.config.ts
file.
If you are on NextJS 15 or later, no action is needed.
OTEL_EXPORTER_OTLP_ENDPOINT
is the HoneyHive API endpoint for consuming NextJS telemetry data.
OTEL_EXPORTER_OTLP_HEADERS
are the headers that contain the HoneyHive API key and project name.
If setting these in your .env
file, make sure to reload your application after setting the variables.
sessionId
and passing it to your AI SDK call.
A valid sessionId
is a random uuidv4 string.
For example, you can generate a sessionId when your client-side page is mounted:
First, install uuid
:
sessionId
will help us link multiple traces to the same user session.
You can find a complete example of this integration in our NextJS Cookbook.