Next.js Integration with Laminar Tracing for AI Applications
Initialize a Next.js app
Install Dependencies
Environment Setup
.env.local
file.
Get Laminar project API key.
Get OpenAI API key.
Get Anthropic API key.Update next.config.ts
next.config.ts
file:Project Structure
instrumentation.ts
file in the Next.js docs.
instrumentation.ts
file is ideal for this purpose as it’s loaded early in the application lifecycle.experimental_telemetry
in the generateText
function and pass the tracer to it.
http://localhost:3000
in your browserA screenshot of a trace from the example app.
.env.local
fileinstrumentation.ts
filenext.config.ts
file is correctly configured