Vercel
Braintrust integrates with Vercel in two ways: through the Vercel AI SDK for tracing AI applications, and through the Vercel Marketplace for project setup and observability through your Vercel dashboard.
Vercel Marketplace vs. Vercel AI SDK
Both the Vercel Marketplace and Vercel AI SDK approaches enable you to send your Vercel application's AI traces to Braintrust. The method you choose is related to how you want to set up and manage your integration and how much flexibility and control you want over how your traces are logged in Braintrust.
The Vercel Marketplace integration provides less fine-grained control over what parts of your app are traced to Braintrust, but requires almost no code changes to your project. This is a good method for getting set up with Braintrust quickly.
The Vercel AI SDK integration requires installing the Braintrust SDK and adding several lines of code to your project, but allows you more control over what parts of your application are traced. This is a good method for more complex applications where you only want to capture specific traces.
Vercel Marketplace
Braintrust is available as a native integration on the Vercel Marketplace. This integration allows you to run evals, monitor model quality and user experience, and benchmark across models from OpenAI, Anthropic, Gemini, and more from your Vercel dashboard.
Set up the Vercel Marketplace integration
Install the Braintrust integration
From the Vercel Marketplace listing, select Install. You will be prompted to create a new Braintrust account. On the next screen, select either the Free plan or the Pro installation plan and select Continue. Create a name for your Braintrust project in the Product Name field and select Create. This creates a Braintrust project and links it to your Vercel account.
From here, either select Done to go to your integration page or Add Drain to start sending logs to Braintrust.
Add Drain
In the Add Drain panel, select Traces and Next. Create a name for the drain and choose which Vercel projects you want to send traces to Braintrust. You can select All Projects or designate one or several specific projects. Adjust the sampling rate to designate what percentage of Vercel logs are sent to Braintrust.
Configure OpenTelemetry
Once you've added the integration, you need to configure OpenTelemetry on each project that's sending traces to Braintrust. In your Next.js project, create an instrumentation.ts
file and call registerOtel
. Check out the Vercel docs on initializing OTel for an example.
Vercel AI SDK
Braintrust natively supports tracing requests made with the Vercel AI SDK. The Vercel AI SDK is an elegant tool for building AI-powered applications.
Vercel AI SDK v5 (wrapAISDK)
wrapAISDK
wraps the top-level AI SDK functions (generateText
, streamText
, generateObject
, streamObject
) and automatically creates spans with full input/output logging, metrics, and tool call tracing.
Tool calls with wrapAISDK
wrapAISDK
automatically traces both the LLM's tool call suggestions and the actual tool executions. It supports both the array-based and object-based tools
formats from the AI SDK.
Vercel AI SDK v4 (model-level wrapper)
To wrap individual models, you can use wrapAISDKModel
with specific model instances.
Wrapping tools
Wrap tool implementations with wrapTraced
. Here is a full example, modified from the Node.js Quickstart.
When you run this code, you'll see traces like this in the Braintrust UI: