Vercel AI SDK
The Vercel AI SDK is an elegant tool for building AI-powered applications. Braintrust natively supports tracing requests made with the Vercel AI SDK.
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: