The way to instrument your application to automatically collect traces depends on the runtime and framework you are using.
Node.js
Braintrust auto-instrumentation for Node.js uses a startup hook. The hook patches supported AI libraries as your process starts, logging your LLM calls.
Version Requirement: Node.js 18.19.0+ or 20.6.0+ and above.
If you are using a bundler to build your application, also follow the guide for your specific bundler below. (Vite, Esbuild, Rollup, or Webpack)
1
Initialize the logger
Call initLogger() once, as soon as possible on application startup, before making any AI calls. The SDK reads BRAINTRUST_API_KEY from the environment configured above.
import { initLogger } from "braintrust";initLogger({ projectName: "My Project",});
2
Run with the import hook
Start your Node.js application with the Braintrust hook:
node --import braintrust/hook.mjs app.js
After following these steps, calls to your AI provider should be traced.
For a list of all supported AI providers see TypeScript SDK integrations.
Cloudflare
To trace LLM calls from your Cloudflare app, wrap your AI provider’s SDK with Braintrust. The example below uses OpenAI (for other providers, see TypeScript SDK integrations).
If you are using a bundler to build your application, also follow the guide for your specific bundler below. (Vite, Esbuild, Rollup, or Webpack)
Cloudflare Workers
Cloudflare Pages
1
Set Cloudflare secrets
Store your Braintrust API key as Cloudflare secret:
wrangler secret put BRAINTRUST_API_KEY
2
Setting the Node.js compatibility flag
Since the Braintrust SDK uses the Node.js AsyncLocalStorage API, you need to enable Node.js compatibility in your Wrangler configuration:
{ "compatibility_flags": ["nodejs_compat"]}
compatibility_flags = ["nodejs_compat"]
3
Initialize the logger and wrap your client
Inside fetch, initialize the logger with secrets from the env binding, wrap your OpenAI client, and pass logger.flush() to ctx.waitUntil() so buffered logs ship after the response returns.
import { initLogger, wrapOpenAI } from "braintrust";import OpenAI from "openai";interface Env { BRAINTRUST_API_KEY: string; OPENAI_API_KEY: string;}export default { async fetch( request: Request, env: Env, ctx: ExecutionContext, ): Promise<Response> { // Set up the braintrust logger const logger = initLogger({ projectName: "My Project", apiKey: env.BRAINTRUST_API_KEY, }); // Wrap the AI provider client const openAIClient = wrapOpenAI( new OpenAI({ apiKey: env.OPENAI_API_KEY, }), ); try { const result = await openAIClient.responses.create({ model: "gpt-5-mini", input: "What is the capital of France?", }); } finally { // Flush all tracing data to Braintrust in the background ctx.waitUntil(logger.flush()); } return Response.json(result); },};
1
Set Cloudflare secrets
Store your Braintrust API key as Cloudflare secret:
wrangler pages secret put BRAINTRUST_API_KEY
2
Setting the Node.js compatibility flag
Since the Braintrust SDK uses the Node.js AsyncLocalStorage API, you need to enable Node.js compatibility in your Wrangler configuration:
{ "compatibility_flags": ["nodejs_compat"]}
compatibility_flags = ["nodejs_compat"]
3
Initialize the logger and wrap your client
Inside onRequest, initialize the logger with secrets from the context.env binding, wrap your OpenAI client, and pass logger.flush() to context.waitUntil() so buffered logs ship after the response returns.
import { initLogger, wrapOpenAI } from "braintrust";import OpenAI from "openai";interface Env { BRAINTRUST_API_KEY: string; OPENAI_API_KEY: string;}export const onRequest: PagesFunction<Env> = async (context) => { // Set up the braintrust logger const logger = initLogger({ projectName: "My Project", apiKey: context.env.BRAINTRUST_API_KEY, }); // Wrap the AI provider client const openAIClient = wrapOpenAI( new OpenAI({ apiKey: context.env.OPENAI_API_KEY, }), ); try { const result = await openAIClient.responses.create({ model: "gpt-5-mini", input: "What is the capital of France?", }); } finally { // Flush all tracing data to Braintrust in the background context.waitUntil(logger.flush()); } return Response.json(result);};
Deno
To trace LLM calls from your Deno app, wrap your AI provider’s SDK with Braintrust. The example below uses OpenAI (for other providers, see TypeScript SDK integrations).
If you are using a bundler to build your application, also follow the guide for your specific bundler below. (Vite, Esbuild, Rollup, or Webpack)
1
Initialize the logger and wrap your client
Read your BRAINTRUST_API_KEY from Deno.env, initialize Braintrust, and wrap the provider client before making AI calls.
import { initLogger, wrapOpenAI } from "npm:braintrust";import OpenAI from "npm:openai";const braintrustApiKey = Deno.env.get("BRAINTRUST_API_KEY");const logger = initLogger({ projectName: "My Project", apiKey: braintrustApiKey,});const openAIClient = wrapOpenAI(new OpenAI());try { const result = await openAIClient.responses.create({ model: "gpt-5-mini", input: "What is the capital of France?", });} finally { await logger.flush();}console.log(result.output_text);
2
Run with Deno permissions
Grant environment variable access via --allow-env and network access for Braintrust via --allow-net and run your application.
deno run \ --allow-env=BRAINTRUST_API_KEY \ --allow-net=www.braintrust.dev,api.braintrust.dev,api-eu.braintrust.dev \ main.ts
AWS Lambda
To trace LLM calls from a Node.js Lambda function, initialize Braintrust outside the handler once, wrap your AI provider’s SDK, and flush before the invocation returns. AWS Lambda does not keep background promises alive after the handler completes, so set asyncFlush: false when initializing the logger.
If you are using a bundler to build your application, also follow the guide for your specific bundler below. (Vite, Esbuild, Rollup, or Webpack)
1
Initialize the logger and wrap your client
Create the logger and provider client at module scope so Lambda can reuse them across warm invocations.
lambda.ts
import { initLogger, wrapOpenAI } from "braintrust";import OpenAI from "openai";const logger = initLogger({ projectName: "My Project", apiKey: process.env.BRAINTRUST_API_KEY, asyncFlush: false,});const openAIClient = wrapOpenAI(new OpenAI());export async function handler() { try { const result = await openAIClient.responses.create({ model: "gpt-5-mini", input: "What is the capital of France?", }); return { statusCode: 200, headers: { "content-type": "application/json" }, body: JSON.stringify({ answer: result.output_text, }), }; } finally { await logger.flush(); }}
Next.js
To trace LLM calls from a Next.js app, wrap your Next.js config and initialize Braintrust in Next’s instrumentation.ts.
1
Configure the Next.js Config
Wrap your Next.js Config with wrapNextjsConfigWithBraintrust.
next.config.ts
import { createRequire } from "module";import { type NextConfig } from "next";import { wrapNextjsConfigWithBraintrust } from "braintrust/next";const nextConfig: NextConfig = {};export default wrapNextjsConfigWithBraintrust(nextConfig);
2
Initialize the logger
Create instrumentation.ts in the project root, or src/instrumentation.ts if your app uses src/ and initialize the logger.
instrumentation.ts
import { initLogger } from "braintrust";export function register() { if (process.env.NEXT_RUNTIME === "nodejs" || process.env.NEXT_RUNTIME === "edge") { initLogger({ projectName: "My Project", }); }}
Nest.js
To trace LLM calls from a Nest.js application, initialize Braintrust before Nest creates your application module, then start the Node.js process with the Braintrust hook.
1
Initialize the logger
Call initLogger() before NestFactory.create() and adding an import for braintrust/apply-auto-instrumentation. This ensures Braintrust is ready before Nest constructs providers that may create AI clients.
src/main.ts
// Add the `braintrust/apply-auto-instrumentation` import before any other imports.// Import order is important because the Braintrust import can only instrument subsequent imports.import "braintrust/apply-auto-instrumentation":import { NestFactory } from "@nestjs/core";import { initLogger } from "braintrust";import { AppModule } from "./app.module";initLogger({ projectName: "My Project",});async function bootstrap() { const app = await NestFactory.create(AppModule); await app.listen(process.env.PORT ?? 3000);}void bootstrap();
2
Start Nest with the import hook
Update the scripts you use to run Nest so every normal launch path loads braintrust/hook.mjs. For development with nest start, use NODE_OPTIONS so the hook is inherited by the Nest CLI’s Node process. For production, pass --import to the compiled app directly.
To trace LLM calls from a Nitro server, initialize Braintrust when Nitro starts, add the Braintrust Rollup plugin to the Nitro server build, and flush traces from global middleware.
1
Instrument the server bundle
Add the Braintrust Rollup plugin to nitro.config.ts. Nitro builds the server bundle with Rollup, so this instruments supported AI SDK packages during the Nitro build.
nitro.config.ts
import { braintrustRollupPlugin } from "braintrust/rollup";import { defineConfig } from "nitro";export default defineConfig({ rollupConfig: { plugins: [braintrustRollupPlugin()], },});
2
Initialize the logger
Add a Nitro plugin that initializes Braintrust once when Nitro starts.
plugins/braintrust.ts
import { initLogger } from "braintrust";import { definePlugin } from "nitro";export default definePlugin(() => { initLogger({ projectName: "My Project", });});
3
Add a flush middleware
Add a global middleware that runs after each handler calling flush() in a finally block and pass the promise to event.waitUntil().
This will make Nitro keep the runtime alive long enough to send buffered traces after the response is ready on runtimes that are supported (like Vercel and Cloudflare).
Add a server plugin that initializes Braintrust when Nitro starts and schedules a flush after each response.
server/plugins/braintrust.ts
import { initLogger } from "braintrust";export default defineNitroPlugin((nitroApp) => { initLogger({ projectName: "My Project", });});
3
Add a flush middleware
Add a global middleware that runs on each request calling flush() and pass the promise to event.waitUntil().
This will make Nuxt keep the runtime alive long enough to send buffered traces after the response is ready on runtimes that are supported (like Vercel and Cloudflare).
Update the scripts you use to run Nuxt so every normal launch path loads braintrust/hook.mjs. For development with nuxt dev, use NODE_OPTIONS so the hook is inherited by the Nuxt CLI’s Node process. For production, pass --import to the compiled app directly.
To trace LLM calls in React Router Framework applications, add the Braintrust Vite plugin to the config, initialize the logger in the server entry, and add a node import hook to your server start.
1
Instrument the Vite build
Add the Braintrust Vite plugin to vite.config.ts alongside the React Router plugin.
vite.config.ts
import { reactRouter } from "@react-router/dev/vite";import { defineConfig } from "vite";import { braintrustVitePlugin } from "braintrust/vite";export default defineConfig(() => ({ plugins: [ braintrustVitePlugin(), reactRouter(), ],}));
2
Initialize the logger
If your app uses the default hidden server entry, reveal it first:
npx react-router reveal entry.server
Then call initLogger() in the module scope before importing or constructing any AI clients.
app/entry.server.tsx
import { initLogger } from "braintrust";initLogger({ projectName: "My Project",});
To trace LLM calls on SvelteKit applications, add the Braintrust Vite plugin and initialize the braintrust logger.
1
Instrument the Vite build
Add the Braintrust Vite plugin before sveltekit() in vite.config.ts.
vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";import { defineConfig } from "vite";import { braintrustVitePlugin } from "braintrust/vite";export default defineConfig(() => ({ plugins: [ braintrustVitePlugin(), sveltekit(), ],}));
2
Initialize and flush from server hooks
Code in SvelteKit hook modules runs when the app starts. Initialize Braintrust at module scope and flush from handle.
src/hooks.server.ts
import { flush, initLogger } from "braintrust";import { type Handle } from "@sveltejs/kit";initLogger({ projectName: "My Project",});export const handle: Handle = async ({ event, resolve }) => { try { return await resolve(event); } finally { void flush(); }};
TanStack Start
To trace LLM calls from TanStack Start, initialize Braintrust in src/start.ts, add global request middleware to flush traces, and instrument the Vite build.
1
Instrument the Vite build
Add the Braintrust Vite plugin:
vite.config.ts
import { tanstackStart } from "@tanstack/react-start/plugin/vite";import viteReact from "@vitejs/plugin-react";import { nitro } from "nitro/vite";import { defineConfig } from "vite";import { braintrustVitePlugin } from "braintrust/vite";export default defineConfig(() => ({ plugins: [ braintrustVitePlugin(), tanstackStart(), nitro(), viteReact(), ],}));
2
Initialize and flush from global middleware
Initialize Braintrust in module scope of a global middleware and flush in a finally block.
Add the Braintrust Vite plugin to your Vite config. The plugin instruments supported AI packages at build time.
vite.config.ts
import { defineConfig } from "vite";import { braintrustVitePlugin } from "braintrust/vite";export default defineConfig({ plugins: [braintrustVitePlugin()],});
esbuild
Add the Braintrust esbuild plugin to the plugins array in your build script. The plugin runs during bundling and instruments supported AI SDK packages before the bundle is written.
build.ts
import * as esbuild from "esbuild";import { braintrustEsbuildPlugin } from "braintrust/esbuild";await esbuild.build({ entryPoints: ["src/index.ts"], bundle: true, format: "esm", outfile: "dist/index.js", plugins: [braintrustEsbuildPlugin()],});
Webpack
Add the Braintrust Webpack plugin to your Webpack config. The plugin instruments supported AI SDK packages at build time.
webpack.config.ts
import { braintrustWebpackPlugin } from "braintrust/webpack";export default { plugins: [braintrustWebpackPlugin()],};
Rollup
Add the Braintrust Rollup plugin to your Rollup config. The plugin instruments supported AI SDK packages during the Rollup build.
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Braintrust","description":"Braintrust is the active observability platform for instrumenting, understanding, and improving agents. By actively applying intelligence to agent traces and automatically surfacing the most critical patterns, Braintrust gives teams the visibility to understand how agents behave in production and the tools to improve them.","colors":{"primary":"#3a4af8","light":"#3a4af8","dark":"#7e95fc"},"logo":{"light":"https://mintcdn.com/braintrust/u7i5gTV-ad3TRDYt/logo/logo-light.svg?fit=max\u0026auto=format\u0026n=u7i5gTV-ad3TRDYt\u0026q=85\u0026s=23878ca308aee393dcc8c89ed8705189","dark":"https://mintcdn.com/braintrust/u7i5gTV-ad3TRDYt/logo/logo-dark.svg?fit=max\u0026auto=format\u0026n=u7i5gTV-ad3TRDYt\u0026q=85\u0026s=affa9d0eafd44b6cd7fb22c80afee713"},"favicon":"https://mintcdn.com/braintrust/ybJBbXJUYqK_eUdX/images/favicon.ico?fit=max\u0026auto=format\u0026n=ybJBbXJUYqK_eUdX\u0026q=85\u0026s=c9925befa0cf9b6279fab604eff9aad0","api":{},"navbar":{"links":[{"href":"https://braintrust.dev/contact","label":"Request demo"}],"primary":{"type":"button","label":"Start building","href":"https://braintrust.dev/app"}},"footer":{"socials":{"github":"https://github.com/braintrustdata","x":"https://x.com/braintrust","discord":"https://discord.gg/6G8s47F44X","youtube":"https://www.youtube.com/@BraintrustData"},"links":[{"header":"Resources","items":[{"label":"Pricing","href":"https://www.braintrust.dev/pricing"},{"label":"Blog","href":"https://www.braintrust.dev/blog"},{"label":"Careers","href":"https://www.braintrust.dev/careers"},{"label":"Status","href":"https://status.braintrust.dev/"}]}]},"seo":{"metatags":{"og:type":"website","og:site_name":"Braintrust documentation, API reference, and changelog","canonical":"https://docs.braintrust.dev","og:image":"https://www.braintrust.dev/og?template=docs\u0026title=Get+started"},"indexing":"all"},"fonts":{"heading":{"family":"BraintrustDisplayV2-Regular","source":"https://mintlify-assets.b-cdn.net/fonts/bt-sans-regular.woff2","format":"woff2"},"body":{"family":"Inter"}},"icons":{"library":"lucide"},"styling":{"codeblocks":{"theme":{"light":"github-light","dark":"github-dark-dimmed"}},"latex":true},"integrations":{"segment":{"key":"1BTDVX4cF2K1jWOI5Qh91XXKwgJubQ2R"}},"contextual":{"options":["copy","view","assistant","chatgpt","claude","cursor","vscode","mcp","add-mcp","perplexity","grok","aistudio","devin","devin-mcp","windsurf","download-spec","download-pdf"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"braintrust","hasAudioNarration":false,"actualSubdomain":"braintrust","customDomains":["docs.braintrust.dev"],"gitSource":{"type":"github","owner":"braintrustdata","repo":"braintrust","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae4fcf7ed968a0e8f391474","collectionId":"93d39e66-db84-483f-a5c3-b55d9d43d5a4","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae4fcf7ed968a0e8f391474"},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae4ff3d822866cf7d003d86","clientVersion":"0.0.4043","searchFilterCounts":[{"language":"default","tag":"Reference","count":241},{"language":"default","tag":"API","count":173},{"language":"default","tag":"Resources","count":171},{"language":"default","tag":"SDKs","count":127},{"language":"default","tag":"Guides","count":125},{"language":"default","tag":"Integrations","count":97},{"language":"default","tag":"Cookbook","count":44},{"language":"default","tag":"Recipes","count":43},{"language":"default","tag":"Admin","count":38},{"language":"default","tag":"CLI","count":30}]},"assistantConfig":{"enableAskAiButton":true,"enableStarterQuestions":false,"enableAskAiSearchBar":false,"deflection":{"enabled":true,"email":"support@braintrust.dev","showHelpButton":true}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#content-area h1,#content-area h2,#content-area h3,#content-area h4{letter-spacing:-.01em!important;font-weight:400!important}#content-area h1{font-size:2.3rem!important;line-height:1!important}#content-area h2{font-size:1.6rem!important}#content-area h3{font-size:1.4rem!important}h5{font-family:var(--font-family-body-custom, var(--font-inter, sans-serif));font-weight:600!important}.nav-logo{height:22px}img.rounded,picture img{border:1px solid rgb(var(--gray-100))!important}[data-rmiz] img{margin-top:2em;margin-bottom:2em}.dark img.rounded,.dark picture img{border:1px solid rgb(var(--gray-900))!important}#table-of-contents{margin-top:-56px;overflow-x:hidden}#navbar button[aria-label=\"More actions\"],#navigation-items div.sticky.-top-\\[24px\\],#table-of-contents nav>h2{display:none}#table-of-contents-content{margin:0}#content-area .card h2{font-size:1.2rem!important}li[id^=\"/api-reference/\"]{font-size:.8rem;word-break:break-word}li[id^=\"/api-reference/\"] .method-nav-pill{width:54px;flex:none}li[id^=\"/api-reference/\"] .method-nav-pill span{font-size:.6rem;font-weight:500;letter-spacing:0}#content-area h1,.pagination-title{word-break:break-word}div[data-component-part=card-content]:empty{display:none}#navigation-items{padding-top:40px}#sidebar-group li a,#sidebar-group li button,.sidebar-group li a{border-radius:6px;padding-top:4px;padding-bottom:4px}#sidebar-content h5{font-weight:500!important}#content-container{gap:0}#content-container .lg\\:pl-12{padding-left:0;gap:36px}.dark #content-container{background-color:#000}#content-area{max-width:860px}@media (min-width:1024px){#content-container{padding-left:36px;padding-right:36px}}#footer a[href^=\"https://mintlify.com\"],#footer a[href^=\"https://www.mintlify.com\"]{display:none!important}header#header .sm\\:items-center{align-items:flex-start}a[aria-label^=\"Navigate to\"].-ml-10{margin-left:-28px}a[aria-label^=\"Navigate to\"].-ml-10 div:not(:hover){box-shadow:none}.font-mono{font-family:\"SF Mono\",\"Monaco\",\"Inconsolata\",\"Fira Mono\",\"Droid Sans Mono\",\"Source Code Pro\",monospace!important}:root{--primary:43 30 235;--font-jetbrains-mono:\"SF Mono\", \"Monaco\", \"Inconsolata\", \"Fira Mono\", \"Droid Sans Mono\",\n \"Source Code Pro\", monospace}.dark{--primary-light:87 112 255}:root{--code-line-highlight-background:rgb(var(--primary-light) / 0.06);--code-line-highlight-border:rgb(var(--primary-light) / 0.12)}.dark{--code-line-highlight-background:rgb(var(--primary-light) / 0.08);--code-line-highlight-border:rgb(var(--primary-light) / 0.35)}[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight,[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight::after,[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight::before{background:var(--code-line-highlight-background)!important}[data-component-part=code-block-root]:not(.has-line-numbers) .line-highlight::before{border-left-color:var(--code-line-highlight-border)!important}.has-line-numbers .line-highlight::after{background:var(--code-line-highlight-background)!important;border-left-color:var(--code-line-highlight-border)!important}.navbar-link a{border-radius:6px}#topbar-cta-button a span.absolute{background-color:rgb(var(--primary));border-radius:6px}.dark #topbar-cta-button a span.absolute{background-color:rgb(var(--primary-light))}div[data-page-title=\"Page Not Found\"]>div{width:100vw;max-width:none}.dark\\:bg-background-dark:is(.dark *){background-color:#000}html.dark #navbar div.dark\\:bg-background-dark{background-color:rgb(var(--background-dark)/1)}#footer .nav-logo{opacity:.5;width:100px}#footer .max-w-\\[984px\\]{max-width:72rem;padding-left:1.25rem;padding-right:1.25rem}@media (min-width:1024px){#footer .max-w-\\[984px\\]{padding-left:36px;padding-right:36px}}.integrations-search-input{width:100%;height:2.25rem;padding-left:2.75rem;padding-right:.75rem;font-size:.875rem;line-height:1.5rem;border:0;border-radius:9999px;outline:0;background-color:rgba(3,7,18,.03);color:#6b7280;box-shadow:none;transition:background-color .2s}.integrations-search-input:focus,.integrations-search-input:hover{background-color:rgba(3,7,18,.1)}.integrations-search-input:focus{color:#374151}.integrations-search-input::placeholder{color:#4b5563}.dark .integrations-search-input{background-color:rgba(255,255,255,.06);color:rgba(255,255,255,.5)}.dark .integrations-search-input:focus,.dark .integrations-search-input:hover{background-color:rgba(255,255,255,.1)}.dark .integrations-search-input:focus{color:rgba(255,255,255,.9)}.dark .integrations-search-input::placeholder{color:rgba(255,255,255,.5)}.integrations-search-icon,.integrations-search-kbd{color:#6b7280}.dark .integrations-search-icon,.dark .integrations-search-kbd{color:rgba(255,255,255,.5)}.gateway-models-filters{display:flex;align-items:center;gap:.75rem;margin-bottom:1.5rem;flex-wrap:wrap}.gateway-models-provider-wrap{display:flex;align-items:center;gap:.5rem}.models-provider-label{font-size:.875rem;font-weight:500;color:#374151;white-space:nowrap}.dark .models-provider-label{color:rgba(255,255,255,.85)}.models-provider-select{height:2.25rem;min-width:10rem;padding:0 2rem 0 .75rem;font-size:.875rem;line-height:1.5;border:1px solid rgba(3,7,18,.08);border-radius:.5rem;outline:0;background-color:#fff;color:#111827;cursor:pointer;appearance:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .75rem center;transition:border-color .15s,box-shadow .15s}.models-provider-select:hover{border-color:rgba(3,7,18,.18)}.models-provider-select:focus{border-color:rgb(43 30 235);box-shadow:0 0 0 2px rgba(43,30,235,.2)}.dark .models-provider-select{background-color:rgba(255,255,255,.06);border-color:rgba(255,255,255,.12);color:rgba(255,255,255,.9);background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\")}.dark .models-provider-select:hover{border-color:rgba(255,255,255,.22)}.dark .models-provider-select:focus{border-color:rgb(87 112 255);box-shadow:0 0 0 2px rgba(87,112,255,.25)}[data-component-part=accordion-icon],[data-component-part=card-icon]{flex:none}#content-area svg[data-icon]{width:1rem;height:1rem;display:inline;vertical-align:baseline;transform:translateY(-.125rem)}#content-area :not(pre)>code{padding-left:.2rem;padding-right:.2rem;border-radius:3px;background-color:rgb(0 0 0/.05)}#content-area :not(pre)>code:is(.dark *){background-color:rgb(255 255 255/.1)}body.kb-page #sidebar-content{display:none!important}body.kb-page aside:has(#sidebar-content),body.kb-page aside[id*=sidebar]{display:none!important}body.kb-page #content-container{margin-left:0!important;padding-left:24px!important}body.kb-page main{margin-left:0!important}body.kb-page #table-of-contents{display:block!important}div:has(>.tabs-border[data-component-part=tabs-list]){border:1px solid rgb(var(--gray-200));border-radius:16px;padding:0 .75rem .75rem}.dark div:has(>.tabs-border[data-component-part=tabs-list]){border-color:rgb(var(--gray-800))}.tabs-border[data-component-part=tabs-list]{margin-bottom:1rem!important}td [data-base-ui-tooltip-trigger]{text-align:inherit}"}],"page":{"pagePath":"sdks/typescript/install-and-instrument","slug":"/sdks/typescript/install-and-instrument","pageMetadata":{"title":"Install and instrument","description":"Install the TypeScript SDK, set an API key, and configure tracing by hand.","og:image":"https://www.braintrust.dev/og?template=docs\u0026title=Install%20and%20instrument","href":"/sdks/typescript/install-and-instrument"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Install the TypeScript SDK, set an API key, and configure tracing by hand.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,AccordionGroup,Check,CodeBlock,CodeGroup,Heading,Icon,Info,Note,Step,Steps,Tab,Tabs,Visibility,Warning}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!AccordionGroup)_missingMdxReference(`AccordionGroup`,true);if(!Check)_missingMdxReference(`Check`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Icon)_missingMdxReference(`Icon`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);if(!Visibility)_missingMdxReference(`Visibility`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(Note,{children:[`To use an agent for automatic setup, see the `,_jsx(_components.a,{href:`/sdks/typescript/quickstart`,children:`Quickstart`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`sign-up`,children:`Sign up`}),`\n`,_jsxs(_components.p,{children:[`If you don’t have a Braintrust account, sign up for free at `,_jsx(_components.a,{href:`https://www.braintrust.dev/signup`,children:`braintrust.dev`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`install-the-sdk`,children:`Install the SDK`}),`\n`,_jsx(_components.p,{children:`Add the Braintrust SDK to your project using your preferred package manager:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`pnpm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`pnpm`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` add`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` braintrust`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`npm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`npm`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` install`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` braintrust`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` --save`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`yarn`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`yarn`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` add`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` braintrust`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`deno`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`deno`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` add`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` npm:braintrust`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`set-an-api-key`,children:`Set an API key`}),`\n`,_jsxs(_components.p,{children:[`On the `,_jsxs(_components.strong,{children:[_jsx(Icon,{icon:`settings`}),` Settings`]}),` > `,_jsx(_components.a,{href:`https://www.braintrust.dev/app/~/configuration/api-keys`,children:_jsxs(_components.strong,{children:[_jsx(Icon,{icon:`key-square`}),` API keys`]})}),` page,\ncreate an API key. Then, set it as an environment variable:`]}),`\n`,_jsx(CodeBlock,{filename:`.env`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"your-api-key\"`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The SDK picks up your API key automatically. When you’re done testing locally, remember to set it in production.`}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Never put your API key in version control.`})}),`\n`,_jsx(Heading,{level:`2`,id:`configure-tracing`,children:`Configure tracing`}),`\n`,_jsx(_components.p,{children:`The way to instrument your application to automatically collect traces depends on the runtime and framework you are using.`}),`\n`,_jsxs(AccordionGroup,{children:[_jsxs(Accordion,{title:`Node.js`,icon:`https://img.logo.dev/nodejs.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`node-js`,children:[_jsx(_components.p,{children:`Braintrust auto-instrumentation for Node.js uses a startup hook. The hook patches supported AI libraries as your process starts, logging your LLM calls.`}),_jsxs(Info,{children:[_jsx(_components.strong,{children:`Version Requirement:`}),` Node.js 18.19.0+ or 20.6.0+ and above.`]}),_jsxs(Note,{children:[`If you are using a bundler to build your application, also follow the guide for your specific bundler below. (`,_jsx(_components.a,{href:`#vite`,children:`Vite`}),`, `,_jsx(_components.a,{href:`#esbuild`,children:`Esbuild`}),`, `,_jsx(_components.a,{href:`#rollup`,children:`Rollup`}),`, or `,_jsx(_components.a,{href:`#webpack`,children:`Webpack`}),`)`]}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Initialize the logger`,children:[_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`initLogger()`}),` once, as soon as possible on application startup, before making any AI calls. The SDK reads `,_jsx(_components.code,{children:`BRAINTRUST_API_KEY`}),` from the environment configured above.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`]})})})]}),_jsxs(Step,{title:`Run with the import hook`,children:[_jsx(_components.p,{children:`Start your Node.js application with the Braintrust hook:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`node`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` --import`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` app.js`})]}),`\n`]})})})]})]}),_jsxs(_components.p,{children:[`After following these steps, calls to your AI provider should be traced.\nFor a list of all supported AI providers see `,_jsx(_components.a,{href:`/sdks/typescript/sdk-integrations`,children:`TypeScript SDK integrations`}),`.`]})]}),_jsxs(Accordion,{title:`Cloudflare`,icon:`https://img.logo.dev/cloudflare.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`cloudflare`,children:[_jsxs(_components.p,{children:[`To trace LLM calls from your Cloudflare app, wrap your AI provider’s SDK with Braintrust. The example below uses OpenAI (for other providers, see `,_jsx(_components.a,{href:`/sdks/typescript/sdk-integrations`,children:`TypeScript SDK integrations`}),`).`]}),_jsxs(Note,{children:[`If you are using a bundler to build your application, also follow the guide for your specific bundler below. (`,_jsx(_components.a,{href:`#vite`,children:`Vite`}),`, `,_jsx(_components.a,{href:`#esbuild`,children:`Esbuild`}),`, `,_jsx(_components.a,{href:`#rollup`,children:`Rollup`}),`, or `,_jsx(_components.a,{href:`#webpack`,children:`Webpack`}),`)`]}),_jsxs(Tabs,{children:[_jsx(Tab,{title:`Cloudflare Workers`,id:`cloudflare-workers`,children:_jsxs(Steps,{children:[_jsxs(Step,{title:`Set Cloudflare secrets`,children:[_jsx(_components.p,{children:`Store your Braintrust API key as Cloudflare secret:`}),_jsx(CodeGroup,{children:_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`wrangler`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` secret`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` put`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` BRAINTRUST_API_KEY`})]}),`\n`]})})})})]}),_jsxs(Step,{title:`Setting the Node.js compatibility flag`,children:[_jsxs(_components.p,{children:[`Since the Braintrust SDK uses the Node.js `,_jsx(_components.code,{children:`AsyncLocalStorage`}),` API, you need to enable Node.js compatibility in your Wrangler configuration:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`wrangler.jsonc`,numberOfLines:`3`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"compatibility_flags\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: [`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"nodejs_compat\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`wrangler.toml`,numberOfLines:`1`,language:`toml`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`toml`,children:_jsxs(_components.code,{language:`toml`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`compatibility_flags = [`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"nodejs_compat\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`]`})]}),`\n`]})})})]})]}),_jsxs(Step,{title:`Initialize the logger and wrap your client`,children:[_jsxs(_components.p,{children:[`Inside `,_jsx(_components.code,{children:`fetch`}),`, initialize the logger with secrets from the `,_jsx(_components.code,{children:`env`}),` binding, wrap your OpenAI client, and pass `,_jsx(_components.code,{children:`logger.flush()`}),` to `,_jsx(_components.code,{children:`ctx.waitUntil()`}),` so buffered logs ship after the response returns.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`40`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`40`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger, wrapOpenAI } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` OpenAI `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"openai\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`interface`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` string`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` string`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` async`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` fetch`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` request`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Request`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` env`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` ctx`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` ExecutionContext`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` )`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Promise`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`Response`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`> `}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Set up the braintrust logger`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` logger`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Wrap the AI provider client`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` openAIClient`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` wrapOpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` result`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` openAIClient.responses.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`create`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` model: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"gpt-5-mini\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` input: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"What is the capital of France?\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Flush all tracing data to Braintrust in the background`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ctx.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`waitUntil`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(logger.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` Response.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`json`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(result);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]})]})}),_jsx(Tab,{title:`Cloudflare Pages`,id:`cloudflare-pages`,children:_jsxs(Steps,{children:[_jsxs(Step,{title:`Set Cloudflare secrets`,children:[_jsx(_components.p,{children:`Store your Braintrust API key as Cloudflare secret:`}),_jsx(CodeGroup,{children:_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`wrangler`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` pages`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` secret`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` put`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` BRAINTRUST_API_KEY`})]}),`\n`]})})})})]}),_jsxs(Step,{title:`Setting the Node.js compatibility flag`,children:[_jsxs(_components.p,{children:[`Since the Braintrust SDK uses the Node.js `,_jsx(_components.code,{children:`AsyncLocalStorage`}),` API, you need to enable Node.js compatibility in your Wrangler configuration:`]}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`wrangler.jsonc`,numberOfLines:`3`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"compatibility_flags\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: [`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"nodejs_compat\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`wrangler.toml`,numberOfLines:`1`,language:`toml`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`toml`,children:_jsxs(_components.code,{language:`toml`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`compatibility_flags = [`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"nodejs_compat\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`]`})]}),`\n`]})})})]})]}),_jsxs(Step,{title:`Initialize the logger and wrap your client`,children:[_jsxs(_components.p,{children:[`Inside `,_jsx(_components.code,{children:`onRequest`}),`, initialize the logger with secrets from the `,_jsx(_components.code,{children:`context.env`}),` binding, wrap your OpenAI client, and pass `,_jsx(_components.code,{children:`logger.flush()`}),` to `,_jsx(_components.code,{children:`context.waitUntil()`}),` so buffered logs ship after the response returns.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`34`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`34`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger, wrapOpenAI } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` OpenAI `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"openai\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`interface`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` string`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` string`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` onRequest`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` PagesFunction`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`Env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`> `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` async`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` (`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`context`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Set up the braintrust logger`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` logger`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: context.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Wrap the AI provider client`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` openAIClient`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` wrapOpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: context.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` result`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` openAIClient.responses.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`create`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` model: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"gpt-5-mini\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` input: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"What is the capital of France?\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:` // Flush all tracing data to Braintrust in the background`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` context.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`waitUntil`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(logger.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` Response.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`json`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(result);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`};`})}),`\n`]})})})]})]})})]})]}),_jsxs(Accordion,{title:`Deno`,icon:`https://img.logo.dev/deno.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`deno`,children:[_jsxs(_components.p,{children:[`To trace LLM calls from your Deno app, wrap your AI provider’s SDK with Braintrust. The example below uses OpenAI (for other providers, see `,_jsx(_components.a,{href:`/sdks/typescript/sdk-integrations`,children:`TypeScript SDK integrations`}),`).`]}),_jsxs(Note,{children:[`If you are using a bundler to build your application, also follow the guide for your specific bundler below. (`,_jsx(_components.a,{href:`#vite`,children:`Vite`}),`, `,_jsx(_components.a,{href:`#esbuild`,children:`Esbuild`}),`, `,_jsx(_components.a,{href:`#rollup`,children:`Rollup`}),`, or `,_jsx(_components.a,{href:`#webpack`,children:`Webpack`}),`)`]}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Initialize the logger and wrap your client`,children:[_jsxs(_components.p,{children:[`Read your `,_jsx(_components.code,{children:`BRAINTRUST_API_KEY`}),` from `,_jsx(_components.code,{children:`Deno.env`}),`, initialize Braintrust, and wrap the provider client before making AI calls.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`22`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`22`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger, wrapOpenAI } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"npm:braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` OpenAI `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"npm:openai\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` braintrustApiKey`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` Deno.env.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`get`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"BRAINTRUST_API_KEY\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` logger`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: braintrustApiKey,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` openAIClient`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` wrapOpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` result`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` openAIClient.responses.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`create`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` model: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"gpt-5-mini\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` input: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"What is the capital of France?\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`} `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` logger.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`console.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`log`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(result.output_text);`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Run with Deno permissions`,children:[_jsxs(_components.p,{children:[`Grant environment variable access via `,_jsx(_components.code,{children:`--allow-env`}),` and network access for Braintrust via `,_jsx(_components.code,{children:`--allow-net`}),` and run your application.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`deno`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` run`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` --allow-env=BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` --allow-net=www.braintrust.dev,api.braintrust.dev,api-eu.braintrust.dev`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:` \\\\`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` main.ts`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`AWS Lambda`,icon:`https://img.logo.dev/aws.amazon.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`aws-lambda`,children:[_jsxs(_components.p,{children:[`To trace LLM calls from a Node.js Lambda function, initialize Braintrust outside the handler `,_jsx(_components.strong,{children:`once`}),`, wrap your AI provider’s SDK, and flush before the invocation returns. AWS Lambda does not keep background promises alive after the handler completes, so set `,_jsx(_components.code,{children:`asyncFlush: false`}),` when initializing the logger.`]}),_jsxs(Note,{children:[`If you are using a bundler to build your application, also follow the guide for your specific bundler below. (`,_jsx(_components.a,{href:`#vite`,children:`Vite`}),`, `,_jsx(_components.a,{href:`#esbuild`,children:`Esbuild`}),`, `,_jsx(_components.a,{href:`#rollup`,children:`Rollup`}),`, or `,_jsx(_components.a,{href:`#webpack`,children:`Webpack`}),`)`]}),_jsx(Steps,{children:_jsxs(Step,{title:`Initialize the logger and wrap your client`,children:[_jsx(_components.p,{children:`Create the logger and provider client at module scope so Lambda can reuse them across warm invocations.`}),_jsx(CodeBlock,{filename:`lambda.ts`,numberOfLines:`29`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`29`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger, wrapOpenAI } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` OpenAI `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"openai\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` logger`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` apiKey: process.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`BRAINTRUST_API_KEY`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` asyncFlush: `}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`false`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` openAIClient`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` wrapOpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` async`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` function`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` handler`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` result`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` openAIClient.responses.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`create`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` model: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"gpt-5-mini\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` input: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"What is the capital of France?\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` statusCode: `}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`200`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` headers: { `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"content-type\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"application/json\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` body: `}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`JSON`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`stringify`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` answer: result.output_text,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` };`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` logger.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})})]}),_jsxs(Accordion,{title:`Next.js`,icon:`https://img.logo.dev/nextjs.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`next-js`,children:[_jsxs(_components.p,{children:[`To trace LLM calls from a Next.js app, wrap your Next.js config and initialize Braintrust in Next’s `,_jsx(_components.code,{children:`instrumentation.ts`}),`.`]}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Configure the Next.js Config`,children:[_jsxs(_components.p,{children:[`Wrap your Next.js Config with `,_jsx(_components.code,{children:`wrapNextjsConfigWithBraintrust`}),`.`]}),_jsx(CodeBlock,{filename:`next.config.ts`,numberOfLines:`8`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { createRequire } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"module\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`type`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` NextConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"next\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { wrapNextjsConfigWithBraintrust } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/next\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` nextConfig`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` NextConfig`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {};`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` wrapNextjsConfigWithBraintrust`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`nextConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize the logger`,children:[_jsxs(_components.p,{children:[`Create `,_jsx(_components.code,{children:`instrumentation.ts`}),` in the project root, or `,_jsx(_components.code,{children:`src/instrumentation.ts`}),` if your app uses `,_jsx(_components.code,{children:`src/`}),` and initialize the logger.`]}),_jsx(CodeBlock,{filename:`instrumentation.ts`,numberOfLines:`9`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` function`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` register`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` if`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` (process.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`NEXT_RUNTIME`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` ===`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"nodejs\"`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` ||`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` process.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`NEXT_RUNTIME`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` ===`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"edge\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`Nest.js`,icon:`https://img.logo.dev/nestjs.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`nest-js`,children:[_jsx(_components.p,{children:`To trace LLM calls from a Nest.js application, initialize Braintrust before Nest creates your application module, then start the Node.js process with the Braintrust hook.`}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Initialize the logger`,children:[_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`initLogger()`}),` before `,_jsx(_components.code,{children:`NestFactory.create()`}),` and adding an import for `,_jsx(_components.code,{children:`braintrust/apply-auto-instrumentation`}),`. This ensures Braintrust is ready before Nest constructs providers that may create AI clients.`]}),_jsx(CodeBlock,{filename:`src/main.ts`,numberOfLines:`19`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`19`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:\"// Add the `braintrust/apply-auto-instrumentation` import before any other imports.\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-dark\":`#768390`},children:`// Import order is important because the Braintrust import can only instrument subsequent imports.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/apply-auto-instrumentation\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { NestFactory } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@nestjs/core\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { AppModule } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"./app.module\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`async`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` function`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` bootstrap`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` app`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` NestFactory.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`create`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(AppModule);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` app.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`listen`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(process.env.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`PORT`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` ??`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` 3000`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`void`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` bootstrap`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Start Nest with the import hook`,children:[_jsxs(_components.p,{children:[`Update the scripts you use to run Nest so every normal launch path loads `,_jsx(_components.code,{children:`braintrust/hook.mjs`}),`. For development with `,_jsx(_components.code,{children:`nest start`}),`, use `,_jsx(_components.code,{children:`NODE_OPTIONS`}),` so the hook is inherited by the Nest CLI’s Node process. For production, pass `,_jsx(_components.code,{children:`--import`}),` to the compiled app directly.`]}),_jsx(CodeBlock,{filename:`package.json`,numberOfLines:`7`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"scripts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"start\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"NODE_OPTIONS=`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`--import braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` nest start\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"start:dev\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"NODE_OPTIONS=`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`--import braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` nest start --watch\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"start:prod\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"node --import braintrust/hook.mjs dist/main.js\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`Nitro`,icon:`https://img.logo.dev/nitro.build?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`nitro`,children:[_jsx(_components.p,{children:`To trace LLM calls from a Nitro server, initialize Braintrust when Nitro starts, add the Braintrust Rollup plugin to the Nitro server build, and flush traces from global middleware.`}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Instrument the server bundle`,children:[_jsxs(_components.p,{children:[`Add the Braintrust Rollup plugin to `,_jsx(_components.code,{children:`nitro.config.ts`}),`. Nitro builds the server bundle with Rollup, so this instruments supported AI SDK packages during the Nitro build.`]}),_jsx(CodeBlock,{filename:`nitro.config.ts`,numberOfLines:`8`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustRollupPlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/rollup\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"nitro\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` rollupConfig: {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustRollupPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize the logger`,children:[_jsx(_components.p,{children:`Add a Nitro plugin that initializes Braintrust once when Nitro starts.`}),_jsx(CodeBlock,{filename:`plugins/braintrust.ts`,numberOfLines:`8`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { definePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"nitro\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` definePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(() `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Add a flush middleware`,children:[_jsxs(_components.p,{children:[`Add a global middleware that runs after each handler calling `,_jsx(_components.code,{children:`flush()`}),` in a `,_jsx(_components.code,{children:`finally`}),` block and pass the promise to `,_jsx(_components.code,{children:`event.waitUntil()`}),`.\nThis will make Nitro keep the runtime alive long enough to send buffered traces after the response is ready on runtimes that are supported (like Vercel and Cloudflare).`]}),_jsx(CodeBlock,{filename:`middleware/braintrust.ts`,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { flush } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineMiddleware } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"nitro\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineMiddleware`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`async`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` (`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`event`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`, `}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`next`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` next`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` event.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`waitUntil`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]})]}),_jsxs(_components.p,{children:[`After following these steps, calls to your AI provider should be traced.\nFor a list of all supported AI providers see `,_jsx(_components.a,{href:`/sdks/typescript/sdk-integrations`,children:`TypeScript SDK integrations`}),`.`]})]}),_jsxs(Accordion,{title:`Nuxt`,icon:`https://img.logo.dev/nuxt.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`nuxt`,children:[_jsx(_components.p,{children:`To trace LLM calls from a Nuxt app, instrument both Nuxt’s Vite build and Nitro’s server build, then initialize Braintrust from a Nitro plugin.`}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Instrument the Nuxt build`,children:[_jsxs(_components.p,{children:[`Nuxt uses Vite for the client build and Rollup through Nitro for the server build. Add both Braintrust plugins to `,_jsx(_components.code,{children:`nuxt.config.ts`}),`.`]}),_jsx(CodeBlock,{filename:`nuxt.config.ts`,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustRollupPlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/rollup\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustVitePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineNuxtConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` vite: {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustVitePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` nitro: {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` rollupConfig: {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustRollupPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize from a Nitro plugin`,children:[_jsx(_components.p,{children:`Add a server plugin that initializes Braintrust when Nitro starts and schedules a flush after each response.`}),_jsx(CodeBlock,{filename:`server/plugins/braintrust.ts`,numberOfLines:`7`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineNitroPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`((`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`nitroApp`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Add a flush middleware`,children:[_jsxs(_components.p,{children:[`Add a global middleware that runs on each request calling `,_jsx(_components.code,{children:`flush()`}),` and pass the promise to `,_jsx(_components.code,{children:`event.waitUntil()`}),`.\nThis will make Nuxt keep the runtime alive long enough to send buffered traces after the response is ready on runtimes that are supported (like Vercel and Cloudflare).`]}),_jsx(CodeBlock,{filename:`middleware/braintrust.ts`,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { flush } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineEventHandler`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`((`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`event`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` event.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`waitUntil`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`());`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Start Nuxt with the import hook`,children:[_jsxs(_components.p,{children:[`Update the scripts you use to run Nuxt so every normal launch path loads `,_jsx(_components.code,{children:`braintrust/hook.mjs`}),`. For development with `,_jsx(_components.code,{children:`nuxt dev`}),`, use `,_jsx(_components.code,{children:`NODE_OPTIONS`}),` so the hook is inherited by the Nuxt CLI’s Node process. For production, pass `,_jsx(_components.code,{children:`--import`}),` to the compiled app directly.`]}),_jsx(CodeBlock,{filename:`package.json`,numberOfLines:`6`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"scripts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"dev\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"NODE_OPTIONS=`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`--import braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` nuxt dev\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"preview\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"NODE_OPTIONS=`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`--import braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` nuxt preview\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`React Router Framework`,icon:`https://img.logo.dev/reactrouter.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`react-router-framework`,children:[_jsx(_components.p,{children:`To trace LLM calls in React Router Framework applications, add the Braintrust Vite plugin to the config, initialize the logger in the server entry, and add a node import hook to your server start.`}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Instrument the Vite build`,children:[_jsxs(_components.p,{children:[`Add the Braintrust Vite plugin to `,_jsx(_components.code,{children:`vite.config.ts`}),` alongside the React Router plugin.`]}),_jsx(CodeBlock,{filename:`vite.config.ts`,numberOfLines:`11`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { reactRouter } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@react-router/dev/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustVitePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(() `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` ({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` braintrustVitePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` reactRouter`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}))`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize the logger`,children:[_jsx(_components.p,{children:`If your app uses the default hidden server entry, reveal it first:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:`npx`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` react-router`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` reveal`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` entry.server`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Then call `,_jsx(_components.code,{children:`initLogger()`}),` in the module scope before importing or constructing any AI clients.`]}),_jsx(CodeBlock,{filename:`app/entry.server.tsx`,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`]})})})]}),_jsxs(Step,{title:`Add the Braintrust loader hook`,children:[_jsx(_components.p,{children:`Run your server with the Braintrust import hook:`}),_jsx(CodeBlock,{filename:`package.json`,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"scripts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"start\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"NODE_OPTIONS=`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`--import braintrust/hook.mjs`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#F47067`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` react-router-serve ./build/server/index.js\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`SvelteKit`,icon:`https://img.logo.dev/svelte.dev?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`sveltekit`,children:[_jsx(_components.p,{children:`To trace LLM calls on SvelteKit applications, add the Braintrust Vite plugin and initialize the braintrust logger.`}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Instrument the Vite build`,children:[_jsxs(_components.p,{children:[`Add the Braintrust Vite plugin before `,_jsx(_components.code,{children:`sveltekit()`}),` in `,_jsx(_components.code,{children:`vite.config.ts`}),`.`]}),_jsx(CodeBlock,{filename:`vite.config.ts`,numberOfLines:`11`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { sveltekit } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@sveltejs/kit/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustVitePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(() `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` ({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` braintrustVitePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` sveltekit`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}))`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize and flush from server hooks`,children:[_jsxs(_components.p,{children:[`Code in SvelteKit hook modules runs when the app starts. Initialize Braintrust at module scope and flush from `,_jsx(_components.code,{children:`handle`}),`.`]}),_jsx(CodeBlock,{filename:`src/hooks.server.ts`,numberOfLines:`14`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { flush, initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`type`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` Handle } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@sveltejs/kit\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` handle`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`:`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#F69D50`},children:` Handle`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` async`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ({ `}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`event`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`, `}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`resolve`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` resolve`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(event);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` void`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`};`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`TanStack Start`,icon:`https://img.logo.dev/tanstack.com?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`tanstack-start`,children:[_jsxs(_components.p,{children:[`To trace LLM calls from TanStack Start, initialize Braintrust in `,_jsx(_components.code,{children:`src/start.ts`}),`, add global request middleware to flush traces, and instrument the Vite build.`]}),_jsxs(Steps,{children:[_jsxs(Step,{title:`Instrument the Vite build`,children:[_jsx(_components.p,{children:`Add the Braintrust Vite plugin:`}),_jsx(CodeBlock,{filename:`vite.config.ts`,numberOfLines:`15`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { tanstackStart } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@tanstack/react-start/plugin/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` viteReact `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@vitejs/plugin-react\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { nitro } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"nitro/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustVitePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`(() `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` ({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` braintrustVitePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` tanstackStart`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` nitro`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` viteReact`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}))`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Step,{title:`Initialize and flush from global middleware`,children:[_jsxs(_components.p,{children:[`Initialize Braintrust in module scope of a global middleware and flush in a `,_jsx(_components.code,{children:`finally`}),` block.`]}),_jsx(CodeBlock,{filename:`src/start.ts`,numberOfLines:`24`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`24`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` createCsrfMiddleware,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` createMiddleware,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` createStart,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`} `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"@tanstack/react-start\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { flush, initLogger } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`initLogger`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` projectName: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"My Project\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` braintrustMiddleware`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` createMiddleware`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`().`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`server`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` async`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ({ `}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#F69D50`},children:`next`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }) `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` try`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` return`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` await`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` next`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`finally`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` void`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` flush`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` startInstance`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` =`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` createStart`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`(() `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`=>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` ({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` requestMiddleware: [braintrustMiddleware],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}));`})}),`\n`]})})})]}),_jsxs(Step,{title:`Add the Braintrust loader hook`,children:[_jsx(_components.p,{children:`Run your server with the Braintrust import hook:`}),_jsx(CodeBlock,{filename:`package.json`,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"scripts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#8DDB8C`},children:` \"start\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"node --import braintrust/hook.mjs .output/server/index.mjs\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`}`})}),`\n`]})})})]})]})]}),_jsxs(Accordion,{title:`Vite`,icon:`https://img.logo.dev/vite.dev?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`vite`,children:[_jsx(_components.p,{children:`Add the Braintrust Vite plugin to your Vite config. The plugin instruments supported AI packages at build time.`}),_jsx(CodeBlock,{filename:`vite.config.ts`,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { defineConfig } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustVitePlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/vite\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustVitePlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Accordion,{title:`esbuild`,icon:`https://img.logo.dev/esbuild.github.io?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`esbuild`,children:[_jsxs(_components.p,{children:[`Add the Braintrust esbuild plugin to the `,_jsx(_components.code,{children:`plugins`}),` array in your build script. The plugin runs during bundling and instruments supported AI SDK packages before the bundle is written.`]}),_jsx(CodeBlock,{filename:`build.ts`,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:` *`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` as`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` esbuild `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"esbuild\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustEsbuildPlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/esbuild\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`await`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` esbuild.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`build`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` entryPoints: [`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"src/index.ts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` bundle: `}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#6CB6FF`},children:`true`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` format: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"esm\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` outfile: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"dist/index.js\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustEsbuildPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`});`})}),`\n`]})})})]}),_jsxs(Accordion,{title:`Webpack`,icon:`https://img.logo.dev/webpack.js.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`webpack`,children:[_jsx(_components.p,{children:`Add the Braintrust Webpack plugin to your Webpack config. The plugin instruments supported AI SDK packages at build time.`}),_jsx(CodeBlock,{filename:`webpack.config.ts`,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustWebpackPlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/webpack\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustWebpackPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]}),_jsxs(Accordion,{title:`Rollup`,icon:`https://img.logo.dev/rollupjs.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ`,id:`rollup`,children:[_jsx(_components.p,{children:`Add the Braintrust Rollup plugin to your Rollup config. The plugin instruments supported AI SDK packages during the Rollup build.`}),_jsx(CodeBlock,{filename:`rollup.config.ts`,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light github-dark-dimmed`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#22272e`,color:`#24292e`,\"--shiki-dark\":`#adbac7`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` { braintrustRollupPlugin } `}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:` \"braintrust/rollup\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:`export`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#F47067`},children:` default`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` input: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"src/index.ts\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` output: {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` dir: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"dist\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` format: `}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#96D0FF`},children:`\"esm\"`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:` plugins: [`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#DCBDFB`},children:`braintrustRollupPlugin`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`()]`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#F69D50`},children:`}`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#ADBAC7`},children:`;`})]}),`\n`]})})})]})]}),`\n`,_jsxs(Visibility,{for:`agents`,children:[_jsx(_components.p,{children:`Useful setup information:`}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`If you are manually flushing, make sure to put the `,_jsx(_components.code,{children:`flush()`}),` call into a `,_jsx(_components.code,{children:`finally`}),` block so that the SDK still sends your traces even when the code failed. Braintrust will track failing LLM calls.`]}),`\n`,_jsxs(_components.li,{children:[`Even if you are bundling your application using a bundler, set up the platform/runtime specific auto-instrumentation like `,_jsx(_components.code,{children:`--import`}),` in addition to the bundler plugins so that if certain dependencies don’t get bundled, they will still be instrumented.`]}),`\n`,_jsxs(_components.li,{children:[`If you are deploying your application on Cloudflare, find a way to call `,_jsx(_components.code,{children:`flush()`}),` as part of `,_jsx(_components.code,{children:`ctx.waitUntil(flush())`}),`, `,_jsx(_components.code,{children:`event.waitUntil(flush())`}),`, or the framework’s equivalent request-lifetime primitive.`]}),`\n`,_jsxs(_components.li,{children:[`For sveltekit when deploying on Vercel, Netlify or cloudflare, you may need to use the platforms `,_jsx(_components.code,{children:`waitUntil`}),` functionality to properly flush events.`]}),`\n`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`verify-tracing`,children:`Verify tracing`}),`\n`,_jsxs(_components.p,{children:[`Run your app and make an AI call. A trace will show up in your `,_jsx(_components.a,{href:`https://www.braintrust.dev/app/~/logs`,children:`Braintrust Logs`}),`, usually within seconds.`]}),`\n`,_jsx(Check,{children:`If traces appear in Braintrust, you’ve successfully set up the SDK.`}),`\n`,_jsxs(_components.p,{children:[`If your traces don’t appear in Braintrust, see `,_jsx(_components.a,{href:`/sdks/typescript/troubleshooting`,children:`Troubleshooting`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next steps`}),`\n`,_jsx(_components.p,{children:`Learn more about using the SDK to observe, evaluate, and improve your AI application:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/instrument`,children:`Instrument`}),` — trace LLM calls and application logic`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/observe`,children:`Observe`}),` — search and analyze production traces`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/annotate`,children:`Annotate`}),` — label traces and build datasets`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/evaluate`,children:`Evaluate`}),` — measure quality and catch regressions`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/deploy`,children:`Deploy`}),` — ship to production with the AI gateway`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"github-light","dark":"github-dark-dimmed"}},"config":{},"pageMetadata":{"title":"Install and instrument","description":"Install the TypeScript SDK, set an API key, and configure tracing by hand.","og:image":"https://www.braintrust.dev/og?template=docs\u0026title=Install%20and%20instrument","href":"/sdks/typescript/install-and-instrument"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Sign up","slug":"sign-up","depth":2,"children":[]},{"title":"Install the SDK","slug":"install-the-sdk","depth":2,"children":[]},{"title":"Set an API key","slug":"set-an-api-key","depth":2,"children":[]},{"title":"Configure tracing","slug":"configure-tracing","depth":2,"children":[]},{"title":"Verify tracing","slug":"verify-tracing","depth":2,"children":[]},{"title":"Next steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/braintrust/dd75b144de68c9c9/custom.js","/_mintlify/custom/braintrust/0c94fa43664e0c40/utm-attribution.js"],"subdomain":"braintrust","siteName":"Braintrust","title":"Install and instrument - Braintrust","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-22T23:36:52.052Z","originalFileLocation":"sdks/typescript/install-and-instrument.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Install the TypeScript SDK, set an API key, and configure tracing by hand.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Braintrust\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Install and instrument - Braintrust\">\u003cmeta data-mint-head property=\"og:description\" content=\"Install the TypeScript SDK, set an API key, and configure tracing by hand.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Braintrust documentation, API reference, and changelog\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://www.braintrust.dev/og?template=docs\u0026amp;title=Install%20and%20instrument\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Install and instrument - Braintrust\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Install the TypeScript SDK, set an API key, and configure tracing by hand.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://www.braintrust.dev/og?template=docs\u0026amp;title=Install%20and%20instrument\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/braintrust/Pnqso5CFAxfn5afF/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Braintrust\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#3a4af8\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sdks/typescript/install-and-instrument.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.braintrust.dev/#organization\",\"name\":\"Braintrust\",\"url\":\"https://docs.braintrust.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/braintrust/u7i5gTV-ad3TRDYt/logo/logo-light.svg?fit=max\u0026auto=format\u0026n=u7i5gTV-ad3TRDYt\u0026q=85\u0026s=23878ca308aee393dcc8c89ed8705189\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.braintrust.dev#website\",\"name\":\"Braintrust\",\"url\":\"https://docs.braintrust.dev\",\"publisher\":{\"@id\":\"https://docs.braintrust.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument#webpage\",\"url\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument\",\"name\":\"Install and instrument\",\"description\":\"Install the TypeScript SDK, set an API key, and configure tracing by hand.\",\"dateModified\":\"2026-10-22T23:36:52.052Z\",\"isPartOf\":{\"@id\":\"https://docs.braintrust.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Braintrust\",\"item\":\"https://docs.braintrust.dev\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Install and instrument\",\"item\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument#article\",\"headline\":\"Install and instrument\",\"name\":\"Install and instrument\",\"description\":\"Install the TypeScript SDK, set an API key, and configure tracing by hand.\",\"url\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument\",\"mainEntityOfPage\":{\"@id\":\"https://docs.braintrust.dev/sdks/typescript/install-and-instrument#webpage\"},\"image\":\"https://www.braintrust.dev/og?template=docs\u0026title=Install%20and%20instrument\",\"dateModified\":\"2026-10-22T23:36:52.052Z\",\"publisher\":{\"@id\":\"https://docs.braintrust.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.braintrust.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Braintrust\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Braintrust","nav":{"global":null,"tabs":[{"tab":"Guides","icon":"book-open","pages":[{"title":"Guides","href":""}]},{"tab":"Integrations","icon":"plug","pages":[{"title":"Integrations","href":"/integrations"}]},{"tab":"SDKs","icon":"blocks","dropdowns":[{"dropdown":"All SDKs","pages":[{"title":"SDKs","mode":"custom","href":"/sdks"}]},{"dropdown":"TypeScript","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/typescript.svg","pages":[{"title":"TypeScript SDK quickstart","sidebarTitle":"Quickstart","description":"Install the Braintrust TypeScript SDK, instrument your application, and verify that traces appear in Braintrust.","href":"/sdks/typescript/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/typescript/install-and-instrument"},{"title":"TypeScript SDK integrations","sidebarTitle":"SDK integrations","description":"AI providers, agent frameworks, and tools the Braintrust TypeScript SDK integrates with.","href":"/sdks/typescript/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/typescript/troubleshooting"}]},{"group":"Features","icon":"component","pages":[{"title":"Workflow evaluations","href":"/sdks/typescript/workflow-evaluations"},{"title":"Application logs","href":"/sdks/typescript/application-logs"},{"title":"Redact sensitive data","href":"/sdks/typescript/redact-sensitive-data"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/typescript/api-reference"},{"group":"Versions","boost":0.5,"pages":[{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.42.0 (latest)","href":"/sdks/typescript/versions/3.42.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.41.0","href":"/sdks/typescript/versions/3.41.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.40.0","href":"/sdks/typescript/versions/3.40.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.39.0","href":"/sdks/typescript/versions/3.39.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.38.0","href":"/sdks/typescript/versions/3.38.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.37.2","href":"/sdks/typescript/versions/3.37.2"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.36.0","href":"/sdks/typescript/versions/3.36.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.35.0","href":"/sdks/typescript/versions/3.35.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.34.0","href":"/sdks/typescript/versions/3.34.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.33.0","href":"/sdks/typescript/versions/3.33.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.32.0","href":"/sdks/typescript/versions/3.32.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.31.0","href":"/sdks/typescript/versions/3.31.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.30.0","href":"/sdks/typescript/versions/3.30.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.29.0","href":"/sdks/typescript/versions/3.29.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.28.0","href":"/sdks/typescript/versions/3.28.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.27.0","href":"/sdks/typescript/versions/3.27.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.26.0","href":"/sdks/typescript/versions/3.26.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.25.0","href":"/sdks/typescript/versions/3.25.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.24.0","href":"/sdks/typescript/versions/3.24.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.23.1","href":"/sdks/typescript/versions/3.23.1"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.22.0","href":"/sdks/typescript/versions/3.22.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.21.0","href":"/sdks/typescript/versions/3.21.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.20.0","href":"/sdks/typescript/versions/3.20.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.19.0","href":"/sdks/typescript/versions/3.19.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.18.0","href":"/sdks/typescript/versions/3.18.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.17.0","href":"/sdks/typescript/versions/3.17.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.16.0","href":"/sdks/typescript/versions/3.16.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.15.0","href":"/sdks/typescript/versions/3.15.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.14.0","href":"/sdks/typescript/versions/3.14.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.13.0","href":"/sdks/typescript/versions/3.13.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.12.0","href":"/sdks/typescript/versions/3.12.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.11.0","href":"/sdks/typescript/versions/3.11.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.10.0","href":"/sdks/typescript/versions/3.10.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.9.0","href":"/sdks/typescript/versions/3.9.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.8.0","href":"/sdks/typescript/versions/3.8.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.7.1","href":"/sdks/typescript/versions/3.7.1"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.7.0","href":"/sdks/typescript/versions/3.7.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.6.0","href":"/sdks/typescript/versions/3.6.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.5.0","href":"/sdks/typescript/versions/3.5.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.4.0","href":"/sdks/typescript/versions/3.4.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.3.0","href":"/sdks/typescript/versions/3.3.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.2.0","href":"/sdks/typescript/versions/3.2.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.1.0","href":"/sdks/typescript/versions/3.1.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v3.0.0","href":"/sdks/typescript/versions/3.0.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v2.2.2","href":"/sdks/typescript/versions/2.2.2"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v2.1.0","href":"/sdks/typescript/versions/2.1.0"},{"title":"Braintrust TypeScript SDK","sidebarTitle":"v2.0.2","href":"/sdks/typescript/versions/2.0.2"},{"title":"TypeScript SDK","sidebarTitle":"v1.1.1","href":"/sdks/typescript/versions/1.1.1"}]},{"group":"Migration guides","pages":[{"title":"Migrate from v2.x to v3.x","sidebarTitle":"v2.x to v3.x","href":"/sdks/typescript/migrations/v2-to-v3"},{"title":"Migrate from v1.x to v2.x","sidebarTitle":"v1.x to v2.x","href":"/sdks/typescript/migrations/v1-to-v2"},{"title":"Migrate from v0.x to v1.x","sidebarTitle":"v0.x to v1.x","href":"/sdks/typescript/migrations/v0-to-v1"}]},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-javascript/releases?q=js-sdk-\u0026expanded=true","href":"/sdks/typescript/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-javascript","href":"/sdks/typescript/github"}]},{"group":"Related packages","icon":"puzzle","pages":[{"title":"TypeScript SDK: related packages","sidebarTitle":"Overview","href":"/sdks/typescript/related/index"},{"group":"Audio","boost":0.5,"pages":[{"title":"Audio JS package","sidebarTitle":"v0.1.0 (latest)","href":"/sdks/typescript/related/audio/0.1.0"}]},{"group":"Autoevals","boost":0.5,"pages":[{"title":"Autoevals TypeScript API","sidebarTitle":"v0.3.0 (latest)","href":"/sdks/typescript/related/autoevals/0.3.0"},{"title":"Autoevals TypeScript API","sidebarTitle":"v0.0.132","href":"/sdks/typescript/related/autoevals/0.0.132"},{"title":"Autoevals TypeScript API","sidebarTitle":"v0.0.131","href":"/sdks/typescript/related/autoevals/0.0.131"}]},{"group":"LangChain (deprecated)","boost":0.5,"pages":[{"title":"LangChain JS Integration","sidebarTitle":"v0.2.5 (latest)","href":"/sdks/typescript/related/langchain/0.2.5"},{"title":"LangChain JS Integration","sidebarTitle":"v0.2.4","href":"/sdks/typescript/related/langchain/0.2.4"}]},{"group":"OpenAI Agents","boost":0.5,"pages":[{"title":"OpenAI Agents JS Integration","sidebarTitle":"v0.1.7 (latest)","href":"/sdks/typescript/related/openai-agents/0.1.7"},{"title":"OpenAI Agents JS Integration","sidebarTitle":"v0.1.6","href":"/sdks/typescript/related/openai-agents/0.1.6"}]},{"group":"OpenTelemetry","boost":0.5,"pages":[{"title":"OpenTelemetry JS Integration","sidebarTitle":"v1.1.0 (latest)","href":"/sdks/typescript/related/otel/1.1.0"},{"title":"OpenTelemetry JS Integration","sidebarTitle":"v1.0.2","href":"/sdks/typescript/related/otel/1.0.2"},{"title":"OpenTelemetry JS Integration","sidebarTitle":"v1.0.0","href":"/sdks/typescript/related/otel/1.0.0"}]}]}]},{"dropdown":"Python","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/python.svg","pages":[{"title":"Python SDK quickstart","sidebarTitle":"Quickstart","href":"/sdks/python/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/python/install-and-instrument"},{"title":"Python SDK integrations","sidebarTitle":"SDK integrations","href":"/sdks/python/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/python/troubleshooting"}]},{"group":"Features","icon":"component","pages":[{"title":"Workflow evaluations","href":"/sdks/python/workflow-evaluations"},{"title":"Application logs","href":"/sdks/python/application-logs"},{"title":"Redact sensitive data","href":"/sdks/python/redact-sensitive-data"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/python/api-reference"},{"group":"Versions","boost":0.5,"pages":[{"title":"Braintrust Python SDK","sidebarTitle":"v0.49.1 (latest)","href":"/sdks/python/versions/0.49.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.48.1","href":"/sdks/python/versions/0.48.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.47.0","href":"/sdks/python/versions/0.47.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.46.1","href":"/sdks/python/versions/0.46.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.45.0","href":"/sdks/python/versions/0.45.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.44.1","href":"/sdks/python/versions/0.44.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.43.0","href":"/sdks/python/versions/0.43.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.42.0","href":"/sdks/python/versions/0.42.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.41.1","href":"/sdks/python/versions/0.41.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.40.0","href":"/sdks/python/versions/0.40.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.39.0","href":"/sdks/python/versions/0.39.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.38.0","href":"/sdks/python/versions/0.38.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.37.0","href":"/sdks/python/versions/0.37.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.36.0","href":"/sdks/python/versions/0.36.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.35.0","href":"/sdks/python/versions/0.35.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.34.0","href":"/sdks/python/versions/0.34.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.33.0","href":"/sdks/python/versions/0.33.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.32.0","href":"/sdks/python/versions/0.32.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.31.1","href":"/sdks/python/versions/0.31.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.31.0","href":"/sdks/python/versions/0.31.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.30.1","href":"/sdks/python/versions/0.30.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.30.0","href":"/sdks/python/versions/0.30.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.29.0","href":"/sdks/python/versions/0.29.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.28.0","href":"/sdks/python/versions/0.28.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.27.0","href":"/sdks/python/versions/0.27.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.26.0","href":"/sdks/python/versions/0.26.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.25.0","href":"/sdks/python/versions/0.25.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.24.0","href":"/sdks/python/versions/0.24.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.23.0","href":"/sdks/python/versions/0.23.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.22.1","href":"/sdks/python/versions/0.22.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.21.0","href":"/sdks/python/versions/0.21.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.20.0","href":"/sdks/python/versions/0.20.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.19.0","href":"/sdks/python/versions/0.19.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.18.0","href":"/sdks/python/versions/0.18.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.17.0","href":"/sdks/python/versions/0.17.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.16.0","href":"/sdks/python/versions/0.16.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.15.0","href":"/sdks/python/versions/0.15.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.14.0","href":"/sdks/python/versions/0.14.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.13.0","href":"/sdks/python/versions/0.13.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.12.1","href":"/sdks/python/versions/0.12.1"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.11.0","href":"/sdks/python/versions/0.11.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.10.0","href":"/sdks/python/versions/0.10.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.9.0","href":"/sdks/python/versions/0.9.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.8.0","href":"/sdks/python/versions/0.8.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.7.0","href":"/sdks/python/versions/0.7.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.6.0","href":"/sdks/python/versions/0.6.0"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.5.6","href":"/sdks/python/versions/0.5.6"},{"title":"Braintrust Python SDK","sidebarTitle":"v0.4.3","href":"/sdks/python/versions/0.4.3"},{"title":"Python SDK","sidebarTitle":"v0.3.15","href":"/sdks/python/versions/0.3.15"}]},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-python/releases","href":"/sdks/python/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-python","href":"/sdks/python/github"}]},{"group":"Related packages","icon":"puzzle","pages":[{"title":"Python SDK: related packages","sidebarTitle":"Overview","href":"/sdks/python/related/index"},{"group":"Autoevals","boost":0.5,"pages":[{"title":"Autoevals Python API","sidebarTitle":"v0.3.0 (latest)","href":"/sdks/python/related/autoevals/0.3.0"},{"title":"Autoevals Python API","sidebarTitle":"v0.2.0","href":"/sdks/python/related/autoevals/0.2.0"},{"title":"Autoevals Python API","sidebarTitle":"v0.1.0","href":"/sdks/python/related/autoevals/0.1.0"},{"title":"Autoevals Python API","sidebarTitle":"v0.0.131","href":"/sdks/python/related/autoevals/0.0.131"},{"title":"Autoevals Python API","sidebarTitle":"v0.0.130","href":"/sdks/python/related/autoevals/0.0.130"}]},{"group":"LangChain (deprecated)","boost":0.5,"pages":[{"title":"LangChain Python Integration","sidebarTitle":"v0.3.0 (deprecated)","href":"/sdks/python/related/langchain/0.3.0"},{"title":"LangChain Python Integration","sidebarTitle":"v0.2.1 (deprecated)","href":"/sdks/python/related/langchain/0.2.1"},{"title":"LangChain Python Integration","sidebarTitle":"v0.2.0 (deprecated)","href":"/sdks/python/related/langchain/0.2.0"},{"title":"LangChain Python Integration","sidebarTitle":"v0.1.5 (deprecated)","href":"/sdks/python/related/langchain/0.1.5"}]},{"group":"Google ADK (deprecated)","boost":0.5,"pages":[{"title":"Google ADK Integration","sidebarTitle":"v0.4.0 (deprecated)","href":"/sdks/python/related/adk/0.4.0"},{"title":"Google ADK Integration","sidebarTitle":"v0.3.1 (deprecated)","href":"/sdks/python/related/adk/0.3.1"},{"title":"Google ADK Integration","sidebarTitle":"v0.2.4 (deprecated)","href":"/sdks/python/related/adk/0.2.4"}]}]}]},{"dropdown":"Go","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/go.svg","pages":[{"title":"Go SDK quickstart","sidebarTitle":"Quickstart","href":"/sdks/go/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/go/install-and-instrument"},{"title":"Go SDK integrations","sidebarTitle":"SDK integrations","href":"/sdks/go/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/go/troubleshooting"}]},{"group":"Features","icon":"component","pages":[{"title":"Workflow evaluations","href":"/sdks/go/workflow-evaluations"},{"title":"Redact sensitive data","href":"/sdks/go/redact-sensitive-data"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/go/api-reference"},{"group":"Versions","boost":0.5,"pages":[{"title":"Braintrust Go SDK","sidebarTitle":"v0.19.0 (latest)","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.19.0","href":"/sdks/go/versions/0.19.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.18.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.18.0","href":"/sdks/go/versions/0.18.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.17.2","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.17.2","href":"/sdks/go/versions/0.17.2"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.17.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.17.1","href":"/sdks/go/versions/0.17.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.17.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.17.0","href":"/sdks/go/versions/0.17.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.16.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.16.0","href":"/sdks/go/versions/0.16.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.15.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.15.0","href":"/sdks/go/versions/0.15.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.14.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.14.0","href":"/sdks/go/versions/0.14.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.13.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.13.0","href":"/sdks/go/versions/0.13.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.12.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.12.0","href":"/sdks/go/versions/0.12.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.11.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.11.1","href":"/sdks/go/versions/0.11.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.11.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.11.0","href":"/sdks/go/versions/0.11.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.10.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.10.0","href":"/sdks/go/versions/0.10.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.9.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.9.1","href":"/sdks/go/versions/0.9.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.9.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.9.0","href":"/sdks/go/versions/0.9.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.8.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.8.0","href":"/sdks/go/versions/0.8.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.7.2","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.7.2","href":"/sdks/go/versions/0.7.2"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.7.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.7.0","href":"/sdks/go/versions/0.7.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.6.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.6.1","href":"/sdks/go/versions/0.6.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.6.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.6.0","href":"/sdks/go/versions/0.6.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.5.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.5.0","href":"/sdks/go/versions/0.5.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.4.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.4.1","href":"/sdks/go/versions/0.4.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.4.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.4.0","href":"/sdks/go/versions/0.4.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.3.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.3.1","href":"/sdks/go/versions/0.3.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.3.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.3.0","href":"/sdks/go/versions/0.3.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.2.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.2.1","href":"/sdks/go/versions/0.2.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.2.0-beta.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.2.0-beta.1","href":"/sdks/go/versions/0.2.0-beta.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.1.2","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.1.2","href":"/sdks/go/versions/0.1.2"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.1.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.1.1","href":"/sdks/go/versions/0.1.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.1.1-beta.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.1.1-beta.1","href":"/sdks/go/versions/0.1.1-beta.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.1.0","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.1.0","href":"/sdks/go/versions/0.1.0"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.0.3","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.0.3","href":"/sdks/go/versions/0.0.3"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.0.2","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.0.2","href":"/sdks/go/versions/0.0.2"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.0.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.0.1","href":"/sdks/go/versions/0.0.1"},{"title":"Braintrust Go SDK","sidebarTitle":"v0.0.1-beta.1","url":"https://pkg.go.dev/github.com/braintrustdata/braintrust-sdk-go@v0.0.1-beta.1","href":"/sdks/go/versions/0.0.1-beta.1"}]},{"group":"Migration guides","pages":[{"title":"Migrate from v0.3.x to v0.4.x","sidebarTitle":"v0.3.x to v0.4.x","href":"/sdks/go/migrations/v0-3-to-v0-4"}]},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-go/releases","href":"/sdks/go/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-go","href":"/sdks/go/github"}]}]},{"dropdown":"Java","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/java.svg","pages":[{"title":"Java SDK quickstart","sidebarTitle":"Quickstart","href":"/sdks/java/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/java/install-and-instrument"},{"title":"Java SDK integrations","sidebarTitle":"SDK integrations","href":"/sdks/java/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/java/troubleshooting"}]},{"group":"Features","icon":"component","pages":[{"title":"Redact sensitive data","href":"/sdks/java/redact-sensitive-data"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/java/api-reference"},{"group":"Versions","boost":0.5,"pages":[{"title":"0.3.26","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.26","href":"/sdks/java/versions/0.3.26"},{"title":"0.3.25","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.25","href":"/sdks/java/versions/0.3.25"},{"title":"0.3.24","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.24","href":"/sdks/java/versions/0.3.24"},{"title":"0.3.23","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.23","href":"/sdks/java/versions/0.3.23"},{"title":"0.3.22","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.22","href":"/sdks/java/versions/0.3.22"},{"title":"0.3.21","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.21","href":"/sdks/java/versions/0.3.21"},{"title":"0.3.20","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.20","href":"/sdks/java/versions/0.3.20"},{"title":"0.3.19","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.19","href":"/sdks/java/versions/0.3.19"},{"title":"0.3.18","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.18","href":"/sdks/java/versions/0.3.18"},{"title":"0.3.17","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.17","href":"/sdks/java/versions/0.3.17"},{"title":"0.3.16","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.16","href":"/sdks/java/versions/0.3.16"},{"title":"0.3.15","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.15","href":"/sdks/java/versions/0.3.15"},{"title":"0.3.14","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.14","href":"/sdks/java/versions/0.3.14"},{"title":"0.3.13","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.13","href":"/sdks/java/versions/0.3.13"},{"title":"0.3.12","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.12","href":"/sdks/java/versions/0.3.12"},{"title":"0.3.11","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.11","href":"/sdks/java/versions/0.3.11"},{"title":"0.3.10","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.10","href":"/sdks/java/versions/0.3.10"},{"title":"0.3.9","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.9","href":"/sdks/java/versions/0.3.9"},{"title":"0.3.8","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.8","href":"/sdks/java/versions/0.3.8"},{"title":"0.3.7","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.7","href":"/sdks/java/versions/0.3.7"},{"title":"0.3.6","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.6","href":"/sdks/java/versions/0.3.6"},{"title":"0.3.5","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.5","href":"/sdks/java/versions/0.3.5"},{"title":"0.3.4","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.4","href":"/sdks/java/versions/0.3.4"},{"title":"0.3.3","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.3","href":"/sdks/java/versions/0.3.3"},{"title":"0.3.2","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.2","href":"/sdks/java/versions/0.3.2"},{"title":"0.3.1","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.1","href":"/sdks/java/versions/0.3.1"},{"title":"0.3.0","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.3.0","href":"/sdks/java/versions/0.3.0"},{"title":"0.2.11","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.11","href":"/sdks/java/versions/0.2.11"},{"title":"0.2.10","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.10","href":"/sdks/java/versions/0.2.10"},{"title":"0.2.9","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.9","href":"/sdks/java/versions/0.2.9"},{"title":"0.2.8","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.8","href":"/sdks/java/versions/0.2.8"},{"title":"0.2.7","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.7","href":"/sdks/java/versions/0.2.7"},{"title":"0.2.6","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.6","href":"/sdks/java/versions/0.2.6"},{"title":"0.2.5","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.5","href":"/sdks/java/versions/0.2.5"},{"title":"0.2.4","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.4","href":"/sdks/java/versions/0.2.4"},{"title":"0.2.3","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.3","href":"/sdks/java/versions/0.2.3"},{"title":"0.2.2","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.2","href":"/sdks/java/versions/0.2.2"},{"title":"0.2.1","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.1","href":"/sdks/java/versions/0.2.1"},{"title":"0.2.0","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.2.0","href":"/sdks/java/versions/0.2.0"},{"title":"0.1.3","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.1.3","href":"/sdks/java/versions/0.1.3"},{"title":"0.1.2","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.1.2","href":"/sdks/java/versions/0.1.2"},{"title":"0.1.1","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.1.1","href":"/sdks/java/versions/0.1.1"},{"title":"0.1.0","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.1.0","href":"/sdks/java/versions/0.1.0"},{"title":"0.0.2","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.0.2","href":"/sdks/java/versions/0.0.2"},{"title":"0.0.1","url":"https://javadoc.io/doc/dev.braintrust/braintrust-sdk-java/0.0.1","href":"/sdks/java/versions/0.0.1"}]},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-java/releases","href":"/sdks/java/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-java","href":"/sdks/java/github"}]}]},{"dropdown":"Ruby","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/ruby.svg","pages":[{"title":"Ruby SDK quickstart","sidebarTitle":"Quickstart","href":"/sdks/ruby/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/ruby/install-and-instrument"},{"title":"Ruby SDK integrations","sidebarTitle":"SDK integrations","href":"/sdks/ruby/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/ruby/troubleshooting"}]},{"group":"Features","icon":"component","pages":[{"title":"Redact sensitive data","href":"/sdks/ruby/redact-sensitive-data"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/ruby/api-reference"},{"group":"Versions","boost":0.5,"pages":[{"title":"0.6.0","url":"https://gemdocs.org/gems/braintrust/0.6.0/","href":"/sdks/ruby/versions/0.6.0"},{"title":"0.5.0","url":"https://gemdocs.org/gems/braintrust/0.5.0/","href":"/sdks/ruby/versions/0.5.0"},{"title":"0.4.2","url":"https://gemdocs.org/gems/braintrust/0.4.2/","href":"/sdks/ruby/versions/0.4.2"},{"title":"0.4.1","url":"https://gemdocs.org/gems/braintrust/0.4.1/","href":"/sdks/ruby/versions/0.4.1"},{"title":"0.4.0","url":"https://gemdocs.org/gems/braintrust/0.4.0/","href":"/sdks/ruby/versions/0.4.0"},{"title":"0.3.2","url":"https://gemdocs.org/gems/braintrust/0.3.2/","href":"/sdks/ruby/versions/0.3.2"},{"title":"0.3.1","url":"https://gemdocs.org/gems/braintrust/0.3.1/","href":"/sdks/ruby/versions/0.3.1"},{"title":"0.3.0","url":"https://gemdocs.org/gems/braintrust/0.3.0/","href":"/sdks/ruby/versions/0.3.0"},{"title":"0.2.1","url":"https://gemdocs.org/gems/braintrust/0.2.1/","href":"/sdks/ruby/versions/0.2.1"},{"title":"0.2.0","url":"https://gemdocs.org/gems/braintrust/0.2.0/","href":"/sdks/ruby/versions/0.2.0"},{"title":"0.1.4","url":"https://gemdocs.org/gems/braintrust/0.1.4/","href":"/sdks/ruby/versions/0.1.4"},{"title":"0.1.3","url":"https://gemdocs.org/gems/braintrust/0.1.3/","href":"/sdks/ruby/versions/0.1.3"},{"title":"0.1.2","url":"https://gemdocs.org/gems/braintrust/0.1.2/","href":"/sdks/ruby/versions/0.1.2"},{"title":"0.1.1","url":"https://gemdocs.org/gems/braintrust/0.1.1/","href":"/sdks/ruby/versions/0.1.1"},{"title":"0.1.0","url":"https://gemdocs.org/gems/braintrust/0.1.0/","href":"/sdks/ruby/versions/0.1.0"},{"title":"0.0.12","url":"https://gemdocs.org/gems/braintrust/0.0.12/","href":"/sdks/ruby/versions/0.0.12"},{"title":"0.0.11","url":"https://gemdocs.org/gems/braintrust/0.0.11/","href":"/sdks/ruby/versions/0.0.11"},{"title":"0.0.10","url":"https://gemdocs.org/gems/braintrust/0.0.10/","href":"/sdks/ruby/versions/0.0.10"},{"title":"0.0.9","url":"https://gemdocs.org/gems/braintrust/0.0.9/","href":"/sdks/ruby/versions/0.0.9"},{"title":"0.0.8","url":"https://gemdocs.org/gems/braintrust/0.0.8/","href":"/sdks/ruby/versions/0.0.8"},{"title":"0.0.7","url":"https://gemdocs.org/gems/braintrust/0.0.7/","href":"/sdks/ruby/versions/0.0.7"},{"title":"0.0.6","url":"https://gemdocs.org/gems/braintrust/0.0.6/","href":"/sdks/ruby/versions/0.0.6"},{"title":"0.0.5","url":"https://gemdocs.org/gems/braintrust/0.0.5/","href":"/sdks/ruby/versions/0.0.5"},{"title":"0.0.4","url":"https://gemdocs.org/gems/braintrust/0.0.4/","href":"/sdks/ruby/versions/0.0.4"},{"title":"0.0.3","url":"https://gemdocs.org/gems/braintrust/0.0.3/","href":"/sdks/ruby/versions/0.0.3"},{"title":"0.0.2","url":"https://gemdocs.org/gems/braintrust/0.0.2/","href":"/sdks/ruby/versions/0.0.2"},{"title":"0.0.1","url":"https://gemdocs.org/gems/braintrust/0.0.1/","href":"/sdks/ruby/versions/0.0.1"}]},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-ruby/releases","href":"/sdks/ruby/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-ruby","href":"/sdks/ruby/github"}]}]},{"dropdown":"C#","icon":"https://mintlify.s3.us-west-1.amazonaws.com/braintrust/images/sdk-icons/csharp.svg","pages":[{"title":"C# SDK quickstart","sidebarTitle":"Quickstart","href":"/sdks/csharp/quickstart"},{"group":"Use the SDK","icon":"code","pages":[{"title":"Install and instrument","href":"/sdks/csharp/install-and-instrument"},{"title":"C# SDK integrations","sidebarTitle":"SDK integrations","href":"/sdks/csharp/sdk-integrations"},{"title":"Troubleshooting","href":"/sdks/csharp/troubleshooting"}]},{"group":"Reference","icon":"file-text","pages":[{"title":"API reference","href":"/sdks/csharp/api-reference"},{"title":"Changelog","url":"https://github.com/braintrustdata/braintrust-sdk-dotnet/releases","href":"/sdks/csharp/changelog"},{"title":"GitHub","url":"https://github.com/braintrustdata/braintrust-sdk-dotnet","href":"/sdks/csharp/github"}]}]}]},{"tab":"Reference","icon":"code","pages":[{"title":"Reference","href":"/reference"}]},{"tab":"Cookbook","icon":"notebook","pages":[{"title":"Cookbook","href":"/cookbook"}]},{"tab":"Troubleshooting","icon":"wrench","pages":[{"title":"Troubleshooting","href":"/kb"}]},{"tab":"Changelog","icon":"mailbox","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Install and instrument - Braintrust","buildId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","deploymentId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","dynamics":[],"chunks":[]}