Installation
Install the Vercel AI SDK, a model provider package, and LangSmith. This guide uses Vercel’s OpenAI integration for the following code snippets, but you can use any other Vercel AI SDK provider.- AI SDK v7
- AI SDK v5 and v6
LangSmithTelemetry requires AI SDK v7 and is available in langsmith>=0.7.2.Environment configuration
Shell
Basic setup
- AI SDK v7
- AI SDK v5 and v6
Register You should see a trace in your LangSmith dashboard like this one.You can also trace runs with tool calls:Which results in a trace like this one.
LangSmithTelemetry once, then use AI SDK methods as you normally would.With traceable
You can wrap traceable calls around AI SDK calls or within AI SDK tool calls. This is useful if you want to group runs together in LangSmith.
- AI SDK v7
- AI SDK v5 and v6
Tracing in serverless environments
When tracing in serverless environments, wait for all runs to flush before your environment shuts down.- AI SDK v7
- AI SDK v5 and v6
Pass a LangSmith
Client instance to LangSmithTelemetry, then call await client.awaitPendingTraceBatches(). Make sure to also pass it into any traceable wrappers you create:Next.js, there is a convenient after hook where you can put this logic:
Passing LangSmith config
You can pass LangSmith-specific config such as metadata, run names, tags, and custom client instances.- AI SDK v7
- AI SDK v5 and v6
If you register the integration globally, the config applies to future AI SDK calls:To apply config to a single run, pass a telemetry integration in that AI SDK call:
Redacting data
You can customize what inputs and outputs the AI SDK sends to LangSmith by specifying custom input/output processing functions. This is useful if you are dealing with sensitive data that you would like to avoid sending to LangSmith. Because output formats vary depending on which AI SDK method you are using, we suggest defining and passing telemetry config individually into AI SDK calls. You will also need to provide separate functions for child LLM runs within AI SDK calls, since callinggenerateText at top level calls the LLM internally and can do so multiple times.
Here’s an example for generateText:
- AI SDK v7
- AI SDK v5 and v6
execute method in a traceable like this:
- AI SDK v7
- AI SDK v5 and v6
traceable return type is complex, which makes the cast necessary. You may also omit the AI SDK tool helper if you wish to avoid the cast.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

