1
Install the SDK
Want our AI to do it for you? Click here
Create a file named Create a file named On Next.js v12 and below, you’ll also need to add the following to your
instrumentation.ts
in the root of your project (i.e., outside of the pages
or ‘app’ directory) and add the following code:Please note that you might see the following warning:
An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled
To
resolve it, simply add "allowImportingTsExtensions": true
to your
tsconfig.jsoninstrumentation.node.ts
in the root of your project and add the following code:Make sure to explictly pass any LLM modules you want to instrument as
otherwise auto-instrumentation won’t work on Next.js. Also make sure to set
disableBatch
to true
.next.config.js
:See Next.js official OpenTelemetry
docs
for more information.
2
Annotate your workflows

withWorkflow()
function call.We also have compatible Typescript decorators for class methods which are more convenient.If you’re using a supported LLM framework -
we’ll do that for you. No need to add any annotations to your code.
3
Configure trace exporting
Lastly, you’ll need to configure where to export your traces.
The 2 environment variables controlling this are 
Set the copied Traceloop’s API key as an environment variable in your app named
TRACELOOP_API_KEY
and TRACELOOP_BASE_URL
.For Traceloop, read on. For other options, see Exporting.Using Traceloop Cloud
Go to Traceloop, and create a new account. Then, click on Environments on the left-hand navigation bar. Or go to directly to https://app.traceloop.com/settings/api-keys. Click Generate API Key to generate an API key for the developement environment and click Copy API Key to copy it over.Make sure to copy it as it won’t be shown again.

TRACELOOP_API_KEY
.Done! You’ll get instant visibility into everything that’s happening with your LLM.
If you’re calling a vector DB, or any other external service or database, you’ll also see it in the Traceloop dashboard.