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

# Voyage AI

> Trace Voyage AI SDK calls in Braintrust to debug prompts, evaluate models, and monitor production usage

If you are a coding agent, prefer the Braintrust [`bt` CLI](/docs/reference/cli/quickstart) for repeatable, scriptable work: running evals, instrumenting code, querying logs, syncing data, managing functions, and configuring coding agents. Use the MCP server for reasoning over Braintrust data in conversation, such as ad-hoc lookups and exploration from your IDE.

[Voyage AI](https://www.voyageai.com/) provides embedding and reranking models. Braintrust traces Voyage AI SDK calls, including text and multimodal embeddings, contextualized embeddings, and reranking.

<View title="TypeScript" icon="https://img.logo.dev/typescriptlang.org?token=pk_BdcHD9e5SCW3j1rnJkNyMQ">
  <h2 id="setup-typescript">
    Setup
  </h2>

  Install the Braintrust and `voyageai` packages, then set your API keys. Requires `voyageai` v0.2.0 or later.

  <Steps>
    <Step title="Install packages">
      <CodeGroup>
        ```bash pnpm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        pnpm add braintrust voyageai
        ```

        ```bash npm theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        npm install braintrust voyageai
        ```
      </CodeGroup>
    </Step>

    <Step title="Set environment variables">
      ```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      BRAINTRUST_API_KEY=<your-braintrust-api-key>
      VOYAGE_API_KEY=<your-voyage-api-key>

      # For organizations on the EU data plane, use https://api-eu.braintrust.dev
      # For self-hosted deployments, use your data plane URL
      # BRAINTRUST_API_URL=<your-braintrust-api-url>
      ```
    </Step>
  </Steps>

  <h2 id="auto-instrumentation-typescript">
    Auto-instrumentation
  </h2>

  To trace Voyage AI SDK calls without modifying your application code, initialize Braintrust normally, then run your app with Braintrust's import hook to patch the Voyage AI SDK at runtime.

  <Steps>
    <Step title="Initialize Braintrust and call Voyage AI">
      <CodeGroup>
        ```javascript title="trace-voyageai-auto.js" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
        import { initLogger } from "braintrust";
        import { VoyageAIClient } from "voyageai";

        initLogger({
          projectName: "voyageai-example",
          apiKey: process.env.BRAINTRUST_API_KEY,
        });

        const client = new VoyageAIClient({
          apiKey: process.env.VOYAGE_API_KEY,
        });

        const response = await client.embed({
          input: ["Braintrust traces all your AI calls."],
          model: "voyage-3-lite",
        });

        console.log(response.data?.[0]?.embedding?.length);
        ```
      </CodeGroup>
    </Step>

    <Step title="Run with the import hook">
      ```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
      node --import braintrust/hook.mjs trace-voyageai-auto.js
      ```

      The auto-instrumentation example uses plain JavaScript so `node --import` can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.

      <Note>
        If you're using a bundler, see [Trace LLM calls](/docs/instrument/trace-llm-calls#auto-instrumentation) for plugin and loader setup.
      </Note>
    </Step>
  </Steps>

  <h2 id="manual-instrumentation-typescript">
    Manual instrumentation
  </h2>

  To trace Voyage AI clients manually, wrap them yourself with `wrapVoyageAI()`. Use this when you want to instrument specific clients individually rather than all of them globally.

  <CodeGroup>
    ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
    import { initLogger, wrapVoyageAI } from "braintrust";
    import { VoyageAIClient } from "voyageai";

    initLogger({
      projectName: "voyageai-example",
      apiKey: process.env.BRAINTRUST_API_KEY,
    });

    const client = wrapVoyageAI(
      new VoyageAIClient({
        apiKey: process.env.VOYAGE_API_KEY,
      }),
    );

    const response = await client.embed({
      input: ["Braintrust traces all your AI calls."],
      model: "voyage-3-lite",
    });

    console.log(response.data?.[0]?.embedding?.length);
    ```
  </CodeGroup>

  <h2 id="what-traced-typescript">
    What Braintrust traces
  </h2>

  Braintrust patches the `voyageai` SDK and creates an LLM-typed span per call:

  * Embedding spans (`voyageai.embed`): input texts and the model as metadata, output summarized as the number of returned embeddings, and token usage (`prompt_tokens`, `tokens`).
  * Multimodal embedding spans (`voyageai.multimodalEmbed`): multimodal content (text, images, video) as input, output summarized as the number of returned embeddings, and token usage.
  * Rerank spans (`voyageai.rerank`): query and documents as input, results as a list of `{index, relevance_score}` items (capped at 100), and request parameters (`model`, `returnDocuments`, `topK`, `truncation`) as metadata.
  * Contextualized embedding spans (`voyageai.contextualizedEmbed`): inputs and model as metadata, output summarized as the total number of returned embeddings, and token usage.
  * Response metadata (model name when returned by the API).
  * Errors captured on every call.

  <h2 id="resources-typescript">
    Resources
  </h2>

  * [Voyage AI TypeScript SDK](https://github.com/voyage-ai/typescript-sdk).
  * [Voyage AI API reference](https://docs.voyageai.com/reference/).
</View>
