Skip to main content
Voyage AI provides embedding and reranking models. Braintrust traces Voyage AI SDK calls, including text and multimodal embeddings, contextualized embeddings, and reranking.

Setup

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

Install packages

2

Set environment variables

.env

Auto-instrumentation

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.
1

Initialize Braintrust and call Voyage AI

2

Run with the import hook

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.
If you’re using a bundler, see Trace LLM calls for plugin and loader setup.

Manual instrumentation

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.

What Braintrust traces

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.

Resources