Protip: wanna to get started even faster? Copy our llms.txt and ask an AI to do this integration
Prerequisites
- Obtain your
LANGWATCH_API_KEY
from the LangWatch dashboard.
Installation
Configuration
EnsureLANGWATCH_API_KEY
is set:
.env
Basic Concepts
- Each message triggering your LLM pipeline as a whole is captured with a Trace.
- A Trace contains multiple Spans, which are the steps inside your pipeline.
- Traces can be grouped together on LangWatch Dashboard by having the same
thread_id
in their metadata, making the individual messages become part of a conversation.- It is also recommended to provide the
user_id
metadata to track user analytics.
- It is also recommended to provide the
Integration
The Vercel AI SDK supports tracing via Next.js OpenTelemetry integration. By using theLangWatchExporter
, you can automatically collect those traces to LangWatch.
First, you need to install the necessary dependencies:
You need to enable the Next, you need to create a file named (Read more about Next.js OpenTelemetry configuration on the official guide)Finally, enable
instrumentationHook
in your next.config.js
file if you haven’t already:instrumentation.ts
(or .js
) in the root directory of the project (or inside src
folder if using one), with LangWatchExporter
as the traceExporter:experimental_telemetry
tracking on the AI SDK calls you want to trace:
Example Project
You can find a full example project with a more complex pipeline and Vercel AI SDK and LangWatch integration on our GitHub.Related Documentation
For more advanced Vercel AI SDK integration patterns and best practices:- Integration Guide - Basic setup and core concepts
- Manual Instrumentation - Advanced span management for Vercel AI SDK calls
- Semantic Conventions - Vercel AI SDK-specific attributes and conventions
- Debugging and Troubleshooting - Debug Vercel AI SDK integration issues
- Capturing Metadata - Adding custom metadata to Vercel AI SDK calls
For production Vercel AI SDK applications, combine manual instrumentation with Semantic Conventions for consistent observability and better analytics.