> ## Documentation Index
> Fetch the complete documentation index at: https://docs.braintrust.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel

> Trace Vercel AI SDK calls and collect Vercel Marketplace traces in Braintrust

Braintrust integrates with [Vercel](https://vercel.com) in two ways: trace calls from the Vercel AI SDK in your application, or collect traces through the Vercel Marketplace integration.

**TypeScript**

## Vercel AI SDK tracing

Braintrust traces [Vercel AI SDK](https://sdk.vercel.ai/docs/ai-sdk-core) text generation, object generation, embeddings, reranking, streaming, tool calls, and agent calls from the Vercel AI SDK.

### Setup

Install the Braintrust SDK alongside the Vercel AI SDK. The Braintrust SDK supports Vercel AI SDK v3, v4, v5, v6, and v7.

```bash pnpm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
pnpm add braintrust ai zod
```

```bash npm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
npm install braintrust ai zod
```

> [!NOTE]
>
> Starting with Braintrust SDK v2.0.0, `zod` is a peer dependency and must be installed separately when using the Vercel AI SDK integration.

### Auto-instrumentation

To trace Vercel AI SDK calls without wrapping individual functions, initialize Braintrust normally, then run your app with Braintrust's import hook. The hook patches AI SDK calls at runtime, including AI SDK v7 telemetry dispatchers.

**1. Initialize Braintrust and call the AI SDK**

```javascript title="trace-vercel-ai-sdk-auto.js" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { initLogger } from "braintrust";

initLogger({
  projectName: "My AI Project",
  apiKey: process.env.BRAINTRUST_API_KEY,
});

async function main() {
  const { text } = await generateText({
    model: openai("gpt-5-mini"),
    prompt: "What is the capital of France?",
  });
  console.log(text);
}

main().catch(console.error);
```

**2. Run with the import hook**

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
node --import braintrust/hook.mjs trace-vercel-ai-sdk-auto.js
```

The auto-instrumentation example uses plain JavaScript so `node --import` can run the file directly. The Braintrust APIs work the same in TypeScript projects. Compile your TypeScript to JavaScript and run the compiled file with the import hook, or [run TypeScript directly](https://docs.braintrust.dev/instrument/trace-llm-calls.md#auto-instrumentation) with a TypeScript loader.

> [!NOTE]
>
> If you're using a bundler, see [Trace LLM calls](https://docs.braintrust.dev/instrument/trace-llm-calls.md#auto-instrumentation) for plugin and loader setup.

For Next.js apps, wrap your Next.js config with `wrapNextjsConfigWithBraintrust` instead of using the Node.js import hook directly. Braintrust uses the wrapper to apply the right instrumentation for the active Next.js build, including webpack and Turbopack builds.

```javascript title="next.config.mjs" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { wrapNextjsConfigWithBraintrust } from "braintrust/next";

const nextConfig = {};

export default wrapNextjsConfigWithBraintrust(nextConfig);
```

### Manual instrumentation (telemetry registration)

For AI SDK v7, call `ai.registerTelemetry(braintrustAISDKTelemetry())` once at startup before making AI SDK calls. Use this path when you cannot run with the import hook or need to instrument a specific call path yourself.

```typescript title="trace-vercel-ai-sdk-v7.ts" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import * as ai from "ai";
import { openai } from "@ai-sdk/openai";
import { braintrustAISDKTelemetry, initLogger } from "braintrust";

initLogger({
  projectName: "My AI Project",
  apiKey: process.env.BRAINTRUST_API_KEY,
});

ai.registerTelemetry(braintrustAISDKTelemetry());

async function main() {
  const { text } = await ai.generateText({
    model: openai("gpt-5-mini"),
    prompt: "What is the capital of France?",
  });
  console.log(text);
}

main().catch(console.error);
```

> [!NOTE]
>
> For AI SDK v7, define tool schemas with `inputSchema`. Braintrust traces requests, streams, and tool calls, but provider-level cache metrics and deny-output overrides from the earlier provider-wrapping integration are not available through v7 telemetry.
>
> For `experimental_evaluate()` calls, use `wrapAISDK()` or the import hook with Braintrust v3.34.0+ and AI SDK v7.0.103 or later within v7. With Braintrust v3.38.0+, `wrapAISDK()` also wraps `experimental_decide()` (AI SDK v7.0.128 or later), and `braintrustAISDKTelemetry()` traces decision calls through the telemetry callbacks that AI SDK v7.0.111 and later emit. These calls produce `evaluate` spans with type `question`, which the trace view labels as **Decision** spans. Inline images and files in decision inputs are captured as attachments when `BRAINTRUST_CAPTURE_ATTACHMENTS` is enabled, and recorded as `<omitted>` otherwise. See [Trace TypeSafe Jev with AI SDK](https://docs.braintrust.dev/integrations/ai-providers/typesafe.md#manual-instrumentation-ai-sdk-typescript).

### Manual instrumentation (wrap functions)

For AI SDK v3 to v6, use `wrapAISDK` to wrap the Vercel AI SDK functions when you cannot run with the import hook or need to instrument a specific call path yourself.

```typescript title="trace-vercel-ai-sdk.ts" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { initLogger, wrapAISDK } from "braintrust";
import * as ai from "ai";
import { openai } from "@ai-sdk/openai";

initLogger({
  projectName: "My AI Project",
  apiKey: process.env.BRAINTRUST_API_KEY,
});

const { generateText } = wrapAISDK(ai);

async function main() {
  // This will automatically log the request, response, and metrics to Braintrust
  const { text } = await generateText({
    model: openai("gpt-5-mini"),
    prompt: "What is the capital of France?",
  });
  console.log(text);
}

main().catch(console.error);
```

### OpenTelemetry

The [Vercel AI SDK](https://sdk.vercel.ai) natively supports OpenTelemetry and works out of the box with Braintrust, either
via Next.js or Node.js.

#### Next.js

If you are using Next.js, use the Braintrust exporter with `@vercel/otel`:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { registerOTel } from "@vercel/otel";
import { BraintrustExporter } from "@braintrust/otel";

// In your instrumentation.ts file
export function register() {
  registerOTel({
    serviceName: "my-braintrust-app",
    traceExporter: new BraintrustExporter({
      parent: "project_name:your-project-name",
      filterAISpans: true, // Only send AI-related spans
    }),
  });
}
```

Traced LLM calls will appear under the Braintrust project or experiment provided in the `parent` field.

When you call the AI SDK, make sure to set `experimental_telemetry`:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const result = await generateText({
  model: openai("gpt-4o-mini"),
  prompt: "What is 2 + 2?",
  experimental_telemetry: {
    isEnabled: true,
    metadata: {
      query: "weather",
      location: "San Francisco",
    },
  },
});
```

> [!NOTE]
>
> The integration supports streaming functions like `streamText`. Each streamed call will produce `ai.streamText` spans in Braintrust.
>
> ```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
> import { openai } from "@ai-sdk/openai";
> import { streamText } from "ai";
>
> export async function POST(req: Request) {
>   const { prompt } = await req.json();
>
>   const result = await streamText({
>     model: openai("gpt-4o-mini"),
>     prompt,
>     experimental_telemetry: { isEnabled: true },
>   });
>
>   return result.toDataStreamResponse();
> }
> ```

#### Node.js

If you are using Node.js without a framework, you must configure the `NodeSDK` directly. Here, it's more straightforward
to use the `BraintrustSpanProcessor`.

First, install the necessary dependencies:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
npm install ai @ai-sdk/openai braintrust @braintrust/otel @opentelemetry/sdk-node @opentelemetry/sdk-trace-base zod
```

Then, set up the OpenTelemetry SDK:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { NodeSDK } from "@opentelemetry/sdk-node";
import { generateText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
import { BraintrustSpanProcessor } from "@braintrust/otel";

const sdk = new NodeSDK({
  spanProcessors: [
    new BraintrustSpanProcessor({
      parent: "project_name:your-project-name",
      filterAISpans: true,
    }),
  ],
});

sdk.start();

async function main() {
  const result = await generateText({
    model: openai("gpt-4o-mini"),
    messages: [
      {
        role: "user",
        content: "What are my orders and where are they? My user ID is 123",
      },
    ],
    tools: {
      listOrders: tool({
        description: "list all orders",
        parameters: z.object({ userId: z.string() }),
        execute: async ({ userId }) =>
          `User ${userId} has the following orders: 1`,
      }),
      viewTrackingInformation: tool({
        description: "view tracking information for a specific order",
        parameters: z.object({ orderId: z.string() }),
        execute: async ({ orderId }) =>
          `Here is the tracking information for ${orderId}`,
      }),
    },
    experimental_telemetry: {
      isEnabled: true,
      functionId: "my-awesome-function",
      metadata: {
        something: "custom",
        someOtherThing: "other-value",
      },
    },
    maxSteps: 10,
  });

  await sdk.shutdown();
}

main().catch(console.error);
```

### Trace tool calls

To trace tool calls, add tools to the same instrumented `generateText` call from the setup above. Braintrust records the tool definitions in span metadata and traces tool execution as child spans.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const { text } = await generateText({
  model: openai("gpt-5-mini"),
  prompt: "What is 127 multiplied by 49?",
  tools: {
    multiply: {
      description: "Multiply two numbers",
      inputSchema: z.object({
        a: z.number(),
        b: z.number(),
      }),
      execute: async ({ a, b }: { a: number; b: number }) => a * b,
    },
  },
});
```

### Stream tool responses

To trace streaming tool responses, pass your tools to `streamText`. Braintrust creates `doStream` child spans for streaming LLM calls.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const tools = {
  multiply: {
    description: "Multiply two numbers",
    inputSchema: z.object({
      a: z.number(),
      b: z.number(),
    }),
    execute: async ({ a, b }: { a: number; b: number }) => a * b,
  },
};

const result = streamText({
  model: openai("gpt-5-mini"),
  prompt: "What is 127 multiplied by 49?",
  tools,
});

for await (const delta of result.textStream) {
  process.stdout.write(delta);
}
```

### Add metadata

To attach custom metadata to your AI SDK traces, wrap your AI calls in a parent span using `traced`. Auto-instrumentation and `wrapAISDK` create child spans for AI SDK calls, and you attach your metadata to the parent span.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
return traced(
  async (span) => {
    const { text } = await generateText({
      model: openai("gpt-5-mini"),
      prompt,
    });

    span.log({
      input: prompt,
      output: text,
      metadata: {
        userId,
        userTier,
      },
    });

    return text;
  },
  { name: "generate-with-context", type: "function" }
);
```

This creates a span hierarchy where your parent span contains the metadata, and the AI SDK call appears as a child span with its own metrics and details.

This approach is useful when you need to:

* Add custom metadata like user IDs, session IDs, or feature flags.
* Compute metadata based on async operations, such as fetching user context.
* Add metadata conditionally based on the response.
* Group multiple AI calls under a single parent span with shared metadata.

> [!NOTE]
>
> If you're using the Vercel AI SDK with OpenTelemetry (not `wrapAISDK`), you can use the native `experimental_telemetry.metadata` parameter instead. See the [OpenTelemetry setup](#opentelemetry-typescript) for details.

### Multi-round tool interactions

When using tools, the AI SDK often makes multiple LLM calls to complete the task. Braintrust automatically creates nested spans to give you visibility into each step:

* **Parent span**: `generateText`, `streamText`, `generateObject`, or `streamObject` represents the overall operation.
* **Child spans**: `doGenerate` or `doStream` represent each individual LLM call during the operation.
* **Tool spans**: Tool executions appear as separate spans showing inputs and outputs.

This nested structure helps you understand:

* How many LLM calls were needed to complete the task
* What each LLM call received and returned
* The complete flow of tool calls and responses

For example, a `generateText` call that uses tools might produce this span hierarchy:

* `generateText` (parent)
  * `doGenerate` (first LLM call, decides to use tool)
  * `multiply` (tool execution)
  * `doGenerate` (second LLM call, uses tool result to form response)

### Trace agents

The AI SDK's Agent classes (`Agent`, `Experimental_Agent`, `ToolLoopAgent`, and `WorkflowAgent`, `HarnessAgent`) are automatically traced when you run with the import hook. They are also wrapped and traced when using `wrapAISDK`.

> [!NOTE]
>
> When using AI SDK v5 or v6, individual tool calls within agentic loops are captured as separate child spans with `span_type: "function"`, giving you full visibility into which tools were called, in what order, and with what inputs and outputs. This granular tool call tracing is specific to AI SDK v5 and v6 and is not available in v3 or v4.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const { Experimental_Agent: Agent } = wrapAISDK(ai);

const agent = new Agent({
  model: openai("gpt-5-mini"),
  system: "You are a helpful assistant.",
});

const result = await agent.generate({
  prompt: "What is the capital of France?",
});
```

### Trace batch requests

To trace text batches you submit with the AI SDK's experimental batch API, use Braintrust v3.39.0+ with AI SDK v7.0.108 or later within v7, and record them yourself with `startAISDKBatchTrace()` and `completeAISDKBatchTrace()`. The import hook and `wrapAISDK` don't trace the batch functions, and these two functions don't call the provider. Call `startAISDKBatchTrace()` after you submit the batch, and store the context string it returns with the batch reference and the original requests. After you collect the results, pass them to `completeAISDKBatchTrace()`, which can run in another process.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import * as ai from "ai";
import {
  completeAISDKBatchTrace,
  initLogger,
  startAISDKBatchTrace,
} from "braintrust";

const logger = initLogger({ projectName: "My AI Project" });

const provider = ai.createGateway(); // Replace with your batch provider
const requests = ["one", "two"].map((id) => ({
  id,
  type: "text" as const,
  model: "google/gemini-2.5-flash",
  prompt: `Reply with only the word ${id}.`,
}));

// When you submit the batch
const startTime = Date.now() / 1000;
const submitted = await ai.experimental_startBatch({ provider, requests });
const context = await startAISDKBatchTrace({
  batch: submitted,
  requests,
  startTime,
});
await logger.flush();
// Store the batch reference, requests, and context, for example in your database
const batch = {
  version: submitted.version,
  id: submitted.id,
  provider: submitted.provider,
};

// When the batch finishes, in the same or another process
const status = await ai.experimental_getBatchStatus({ provider, batch });
const results = [];
for await (const item of ai.experimental_getBatchResults({ provider, batch })) {
  results.push(item);
}
await completeAISDKBatchTrace({ batch, requests, context, status, results });
await logger.flush();
```

`completeAISDKBatchTrace()` accepts only results you've already collected into an array. It leaves the spans open while the batch is pending, or when a completed batch is missing results. For a failed batch, it records the batch error on requests that have no result. Pass the same requests you passed to `startAISDKBatchTrace()`. If their IDs or models don't match the context, nothing is recorded. Calling it again with the same context and results updates the same spans. Without a context, it records the inputs and results together under the current span, or as a new trace if there's no current span. Each request needs a unique `id`, a `model`, and `type: "text"`.

### Trace code mode

Braintrust v3.39.0+ traces `experimental_runCodeMode()` calls from [`@ai-sdk/code-mode`](https://www.npmjs.com/package/@ai-sdk/code-mode) v1.0.100 or later (below v2.0.0). With the import hook, calls are traced with no code changes, including calls made by tools from `experimental_createCodeModeTool()` and `experimental_codeModeTool()`. Without the hook, wrap the code mode module with `wrapAISDK`. The wrapper traces calls you make to `experimental_runCodeMode()` directly, but not calls made inside tools from `experimental_createCodeModeTool()` or `experimental_codeModeTool()`. `braintrustAISDKTelemetry()` alone doesn't trace code mode.

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import * as codeModeModule from "@ai-sdk/code-mode";
import { jsonSchema } from "ai";
import { initLogger, wrapAISDK } from "braintrust";

initLogger({ projectName: "My AI Project" });

const codeMode = wrapAISDK(codeModeModule);

const result = await codeMode.experimental_runCodeMode({
  js: "const a = await tools.double({ value: 2 }); return await tools.double(a);",
  tools: {
    double: {
      inputSchema: jsonSchema<{ value: number }>({
        type: "object",
        properties: { value: { type: "number" } },
        required: ["value"],
      }),
      async execute({ value }: { value: number }) {
        return { value: value * 2 };
      },
    },
  },
});
```

Each run produces a `codeMode` tool span with the JavaScript source as input and the return value as output. Each tool the code calls gets a child span named after the tool. When the run happens inside an AI SDK tool call that's already traced, the tool calls nest under that tool's span instead of a separate `codeMode` span.

### Configure for serverless

Braintrust automatically uses Vercel's `waitUntil` functionality when available, allowing you to use `asyncFlush: true` (the default) without blocking requests.

The SDK automatically detects Vercel's environment and uses `waitUntil` to flush logs in the background. No special configuration is needed for Vercel deployments; use `initLogger` as shown in the examples above.

> [!NOTE]
>
> If you're using a serverless environment without `waitUntil` support (like AWS Lambda), set `asyncFlush: false` to ensure logs are flushed before the function terminates. See [Advanced tracing patterns](https://docs.braintrust.dev/instrument/advanced-tracing.md#flush-logs-manually) for more details.

### What Braintrust traces

Braintrust captures the main AI SDK operation, provider calls, and nested tool or agent work as a span hierarchy:

* **AI SDK operation spans** (`generateText`, `streamText`, `generateObject`, and `streamObject`), with prompt-like inputs, final outputs, provider and model metadata, and operation metadata.
* **Provider call spans** (`doGenerate` and `doStream`), with model-call inputs, provider outputs, token metrics, and time-to-first-token for streaming calls.
* **Embedding spans** (`embed`, `embedMany`, and `doEmbed`), with input values, embedding counts or dimensions, and token metrics when the provider reports them.
* **Rerank spans** (`rerank` and `doRerank`), with query, documents, top-N metadata, and ranked outputs.
* **Image generation spans** (`generateImage`), with image prompt as input, generated images stored as Braintrust attachments, and model and provider metadata.
* **Tool execution spans** (`<tool name>`), with tool inputs, outputs, and errors. For a tool that defines `toModelOutput`, the output is the value the model receives, both on the tool span and in the parent span's tool results.
* **Batch spans** (`ai.batch`), with batch ID, provider, status, and request counts, when you record batches with `startAISDKBatchTrace()` and `completeAISDKBatchTrace()`. Each request gets a child `ai.batch.request` span with its messages, model settings, output, finish reason, token metrics, and status.
* **Code mode spans** (`codeMode`), with the JavaScript source as input, the return value as output, and child spans for each tool the code calls.
* **Agent spans** (`Agent.generate`, `Agent.stream`, `ToolLoopAgent.generate`, `ToolLoopAgent.stream`, `WorkflowAgent.stream`, `HarnessAgent.generate`, and `HarnessAgent.stream`), with agent inputs, outputs, model-call child spans, and time-to-first-token for streaming agent calls.

### Vercel AI SDK tracing resources

* [Vercel AI SDK documentation](https://sdk.vercel.ai/docs)
* [Braintrust TypeScript SDK reference](https://docs.braintrust.dev/sdks/typescript/versions/latest.md)
* [Braintrust package on npm](https://www.npmjs.com/package/braintrust)

**Python**

## Setup

Install Braintrust alongside the Vercel AI SDK for Python. The integration requires `ai>=0.4.0`. Install the provider extra that matches the models you call, for example `ai[openai]` for OpenAI models.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
pip install braintrust "ai[openai]"
```

> [!NOTE]
>
> The Vercel AI SDK for Python requires Python 3.12 or later.

## Auto-instrumentation

Call `braintrust.auto_instrument()` before importing the `ai` package. Braintrust registers its telemetry adapter and captures every AI SDK call automatically.

```python title="trace_ai_sdk_auto.py" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import asyncio
import os
import braintrust

braintrust.auto_instrument()
braintrust.init_logger(
    project="My AI Project",  # Replace with your project name
    api_key=os.environ["BRAINTRUST_API_KEY"],
)

import ai

async def main():
    model = ai.get_model("openai:gpt-5-mini")
    async with ai.stream(model, [ai.user_message("What is the capital of France?")]) as stream:
        async for event in stream:
            if isinstance(event, ai.events.TextDelta):
                print(event.chunk, end="")

asyncio.run(main())
```

To disable the Vercel AI SDK instrumentation when calling `auto_instrument()`, pass `ai_sdk=False`:

```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
braintrust.auto_instrument(ai_sdk=False)
```

## Manual setup

To register the Braintrust telemetry adapter without `auto_instrument()`, use `setup_ai_sdk()`. Call it before any `ai` imports.

```python title="trace_ai_sdk_manual.py" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import asyncio
import os
import braintrust

braintrust.setup_ai_sdk(
    project_name="My AI Project",  # Replace with your project name
    api_key=os.environ["BRAINTRUST_API_KEY"],
)

import ai

async def main():
    model = ai.get_model("openai:gpt-5-mini")
    async with ai.stream(model, [ai.user_message("What is the capital of France?")]) as stream:
        async for event in stream:
            if isinstance(event, ai.events.TextDelta):
                print(event.chunk, end="")

asyncio.run(main())
```

## What Braintrust traces

Braintrust captures AI SDK telemetry spans and converts them to Braintrust spans:

* **Generation spans** for text, object, and image generation calls, with prompt messages as input, generated content as output, and token metrics.
* **Streaming spans** for streaming generation calls, with each streamed chunk recorded as part of the output.
* **Tool call spans** (named by tool name) with tool arguments as input and the tool result as output.
* **Reasoning content** from extended thinking models recorded alongside the main output.
* Token usage metrics (prompt, completion, total, cached, and cache-creation tokens) and time to first token when the provider reports them.

## Resources

* [Vercel AI SDK for Python on PyPI](https://pypi.org/project/ai/)
* [Braintrust Python SDK reference](https://docs.braintrust.dev/sdks/python/versions/latest.md)

## Vercel Marketplace tracing

The Vercel Marketplace integration collects traces for AI calls in your Vercel applications with minimal setup. No package installation required.

### Setup

Set up the marketplace integration by installing it from Vercel, linking Braintrust, choosing a plan, and adding a drain.

**1. Install the integration**

Visit the [Vercel Marketplace listing](https://vercel.com/integrations/braintrust) and select **Install**.

**2. Create or link your account**

Create a Braintrust account or link your existing account.

**3. Select a plan and project**

Select a plan and create a project name:

* **Starter**: Free with basic limits.
* **Starter (pay-as-you-go)**: No monthly fee, but charges for usage beyond the free tier. Requires a payment method.
* **Pro**: Higher limits with a monthly fee.

See [Plans and limits](https://docs.braintrust.dev/plans-and-limits.md) for a full comparison.

**4. Add a drain**

Select **Add Drain** to configure trace collection.

### Configure log drain

Choose which trace data Vercel sends to Braintrust and which projects the drain covers.

**1. Select trace data**

In the **Add Drain** panel, select **Traces** and **Next**.

**2. Choose projects**

Choose which Vercel projects to trace (**All Projects** or specific projects).

**3. Set sampling**

Set the sampling rate for trace collection.

### Enable OpenTelemetry

In your Next.js project, create an `instrumentation.ts` file and call `registerOtel` to emit traces to the marketplace drain.

### Vercel Marketplace resources

* [Vercel Marketplace integration](https://vercel.com/integrations/braintrust)
* [Vercel OpenTelemetry docs](https://vercel.com/docs/otel)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.