<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Michael Lynn</title>
    <description>The latest articles on Forem by Michael Lynn (@mlynn).</description>
    <link>https://forem.com/mlynn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34272%2F4c755d25-3dfb-4464-8f4f-faa1e5681c81.jpg</url>
      <title>Forem: Michael Lynn</title>
      <link>https://forem.com/mlynn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mlynn"/>
    <language>en</language>
    <item>
      <title>What If Vector Search with Voyage AI and MongoDB Was Just... Simple?</title>
      <dc:creator>Michael Lynn</dc:creator>
      <pubDate>Tue, 03 Feb 2026 16:37:02 +0000</pubDate>
      <link>https://forem.com/mlynn/voyageai-cli-a-complete-cli-for-voyage-ai-embeddings-reranking-and-mongodb-atlas-vector-search-4j53</link>
      <guid>https://forem.com/mlynn/voyageai-cli-a-complete-cli-for-voyage-ai-embeddings-reranking-and-mongodb-atlas-vector-search-4j53</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" width="1" height="1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;New to Voyage AI? here's a quick background... Voyage AI builds some of the highest-performing embedding and reranking models in the industry. Embedding models convert text into numerical vectors that capture meaning... so a search for "how do I speed up my queries" can match a document about index optimization, even though they share zero words. Reranking models take it a step further, reading your query and each candidate result together to re-score them for precision. Earlier this year, MongoDB acquired Voyage AI and integrated these models directly into Atlas, meaning you can generate embeddings through the same platform where your data already lives. One bill, one dashboard, no extra infrastructure. That's the context... now let's talk about the tool.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I did not set out to build a CLI for Voyage AI... I was trying to answer a question I kept hearing from smart, capable developers who already understood databases and already understood AI. They were not confused. They were exhausted... in the same way I was exhausted when I first started building solutions for and with AI.&lt;/p&gt;

&lt;p&gt;The question always showed up at the same moment. Right after embeddings made sense on paper. Right after Atlas Vector Search started to look promising. Right about this moment, 9 out of 10 times, one of the bright developers would as the same question.&lt;/p&gt;

&lt;p&gt;“How do I get from here to something working?”&lt;/p&gt;

&lt;p&gt;I vividly remember hitting this same wall. I had the models. I had the cluster. I had a terminal open and a notebook full of code that, frankly I did not want to maintain. Every step felt reasonable on its own. Together, they felt heavy. So we've got to 1. Embed text. 2. Store vectors. 3. Create an index. 4. Query. 5. Optionally Rerank. Then debug everything and rerun the whole flow.&lt;/p&gt;

&lt;p&gt;What bothered me was not the complexity. Each of the steps were simple in and of themselves... It was the friction. This was work I needed to do over and over, and every time it pulled me out of the problem I actually wanted to solve.&lt;/p&gt;

&lt;p&gt;At some point I stopped asking how to explain the process better and started asking a different question.&lt;/p&gt;

&lt;p&gt;Why is this not a one-liner?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vai&lt;/code&gt; came out of that moment. Not as a product idea, but as a convenience I wanted for myself. A way to stay in the terminal, move fast, and get from raw text to a meaningful search result without building a small app every time.&lt;/p&gt;

&lt;p&gt;That is the reason this tool exists.&lt;/p&gt;

&lt;p&gt;This post covers every feature. It's long on purpose — consider it the reference guide I wish existed when I started building with vector search.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; &lt;code&gt;vai&lt;/code&gt; (voyageai-cli) is an independent community tool. It is &lt;strong&gt;not&lt;/strong&gt; an official product of MongoDB, Inc. or Voyage AI. For official docs, visit &lt;a href="https://www.mongodb.com/docs/voyageai/" rel="noopener noreferrer"&gt;mongodb.com/docs/voyageai&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Install and Setup
&lt;/h2&gt;

&lt;p&gt;Ok, if you're like me... you're chomping at the bit - let's see some software.  We'll start with installation and then I'll walk you through use cases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; voyageai-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmrlynn%2Fvoyageai-cli%2Frefs%2Fheads%2Fmain%2Fdemo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmrlynn%2Fvoyageai-cli%2Frefs%2Fheads%2Fmain%2Fdemo.gif" alt="demo" width="720" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That gives you the &lt;code&gt;vai&lt;/code&gt; binary. Node.js 18+ required. No Python, no native modules, no build step.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🎸 I chose "vai" because it's short, stands for Voyage AI, and has no copyright issues — but I just love that every time I invoke it, it makes me think of one of my all-time favorite guitar players, &lt;a href="https://en.wikipedia.org/wiki/Steve_Vai" rel="noopener noreferrer"&gt;Steve Vai&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In order to use this thing, you will need two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A Voyage AI API key&lt;/strong&gt; (required for all commands)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A MongoDB connection string&lt;/strong&gt; (only for commands that touch your database: &lt;code&gt;store&lt;/code&gt;, &lt;code&gt;search&lt;/code&gt;, &lt;code&gt;index&lt;/code&gt;, &lt;code&gt;ingest&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Two Endpoints, Two Keys
&lt;/h3&gt;

&lt;p&gt;There are two ways to access the exact same Voyage AI models — and each has its own key format:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;MongoDB Atlas&lt;/th&gt;
&lt;th&gt;Voyage AI Platform&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Endpoint&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://ai.mongodb.com/v1/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;https://api.voyageai.com/v1/&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key prefix&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;al-&lt;/code&gt; (Atlas)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pa-&lt;/code&gt; (Platform)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Where to get it&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Atlas → AI Models → Create Model API Key&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://dash.voyageai.com" rel="noopener noreferrer"&gt;dash.voyageai.com&lt;/a&gt; → API Keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Billing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Through your Atlas invoice&lt;/td&gt;
&lt;td&gt;Through Voyage AI directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Free tier&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;200M tokens, no credit card&lt;/td&gt;
&lt;td&gt;200M tokens, no credit card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Models&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same models, same quality&lt;/td&gt;
&lt;td&gt;Same models, same quality&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Which should you use?&lt;/strong&gt; If you're already on Atlas (and you probably are if you're building software with AI and vector search), the Atlas endpoint keeps everything on one bill and one dashboard. If you want to use Voyage AI models without Atlas, the platform endpoint works standalone.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vai&lt;/code&gt; defaults to the Atlas endpoint. To switch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use Voyage AI platform endpoint instead&lt;/span&gt;
vai config &lt;span class="nb"&gt;set &lt;/span&gt;base-url https://api.voyageai.com/v1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The key must match the endpoint.&lt;/strong&gt; An &lt;code&gt;al-&lt;/code&gt; key only works on &lt;code&gt;ai.mongodb.com&lt;/code&gt;. A &lt;code&gt;pa-&lt;/code&gt; key only works on &lt;code&gt;api.voyageai.com&lt;/code&gt;. If you get a 403 or 401, this mismatch is almost always the reason — &lt;code&gt;vai&lt;/code&gt; will show a hint when it detects this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting Credentials
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Environment variables (simplest)&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;VOYAGE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"al-your-atlas-key"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;MONGODB_URI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mongodb+srv://user:pass@cluster.mongodb.net/"&lt;/span&gt;

&lt;span class="c"&gt;# Or a .env file in your project&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'VOYAGE_API_KEY=al-your-atlas-key'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .env
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'MONGODB_URI=mongodb+srv://...'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .env

&lt;span class="c"&gt;# Or the built-in config store (chmod 600, secrets masked)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"al-your-atlas-key"&lt;/span&gt; | vai config &lt;span class="nb"&gt;set &lt;/span&gt;api-key &lt;span class="nt"&gt;--stdin&lt;/span&gt;
vai config &lt;span class="nb"&gt;set &lt;/span&gt;mongodb-uri &lt;span class="s2"&gt;"mongodb+srv://..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Credentials resolve in order: environment variable → &lt;code&gt;.env&lt;/code&gt; file → &lt;code&gt;~/.vai/config.json&lt;/code&gt;. Higher priority wins.&lt;/p&gt;

&lt;p&gt;Verify everything works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Link the ping you know and love from the command line, &lt;code&gt;vai ping&lt;/code&gt; hits the Voyage AI API and (if &lt;code&gt;MONGODB_URI&lt;/code&gt; is set) your Atlas cluster. Green checkmarks mean you're good.&lt;/p&gt;

&lt;p&gt;Oh, and btw, if you're curious about some of the basics of Voyage AI, embedding, reranking, etc... try &lt;code&gt;vai explain&lt;/code&gt;.  For example:&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;vai explain api-access&lt;/code&gt; for the full deep-dive on endpoint differences.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Commands
&lt;/h2&gt;

&lt;p&gt;Here's a list of the minimal commands I've created as convenience methods for developers working with Voyage AI and MongoDB. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;vai embed&lt;/code&gt; — Generate Embeddings
&lt;/h3&gt;

&lt;p&gt;The most fundamental operation. Takes text, returns a vector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Single text&lt;/span&gt;
vai embed &lt;span class="s2"&gt;"What is MongoDB Atlas?"&lt;/span&gt;

&lt;span class="c"&gt;# Specify model and dimensions&lt;/span&gt;
vai embed &lt;span class="s2"&gt;"search query"&lt;/span&gt; &lt;span class="nt"&gt;--model&lt;/span&gt; voyage-4-large &lt;span class="nt"&gt;--dimensions&lt;/span&gt; 512

&lt;span class="c"&gt;# From a file&lt;/span&gt;
vai embed &lt;span class="nt"&gt;--file&lt;/span&gt; document.txt &lt;span class="nt"&gt;--input-type&lt;/span&gt; document

&lt;span class="c"&gt;# Bulk from stdin (one text per line)&lt;/span&gt;
&lt;span class="nb"&gt;cat &lt;/span&gt;texts.txt | vai embed

&lt;span class="c"&gt;# Just the raw array (for piping to other tools)&lt;/span&gt;
vai embed &lt;span class="s2"&gt;"hello"&lt;/span&gt; &lt;span class="nt"&gt;--output-format&lt;/span&gt; array
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Input types matter.&lt;/strong&gt; When embedding for retrieval, use &lt;code&gt;--input-type query&lt;/code&gt; for search queries and &lt;code&gt;--input-type document&lt;/code&gt; for corpus text. The model internally optimizes the embedding differently for each — queries are short and specific, documents are long and contextual. Mixing them up won't break anything, but matching them improves relevance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dimensions are flexible.&lt;/strong&gt; Voyage 4 models default to 1024 dimensions but support 256–2048 via Matryoshka representation learning. Lower dimensions = cheaper storage and faster search, at some cost to accuracy. For most workloads, 1024 is the sweet spot.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# JSON output for scripting&lt;/span&gt;
vai embed &lt;span class="s2"&gt;"test"&lt;/span&gt; &lt;span class="nt"&gt;--json&lt;/span&gt; | jq &lt;span class="s1"&gt;'.data[0].embedding | length'&lt;/span&gt;
&lt;span class="c"&gt;# → 1024&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;code&gt;vai rerank&lt;/code&gt; — Rerank Documents by Relevance
&lt;/h3&gt;

&lt;p&gt;Reranking is the step most search implementations skip — and it's the one that makes the biggest difference.&lt;/p&gt;

&lt;p&gt;Embedding models encode queries and documents &lt;em&gt;independently&lt;/em&gt;. A reranker reads the query and each document &lt;em&gt;together&lt;/em&gt; using cross-attention. It's slower (50–200ms for a batch) but dramatically more accurate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Inline documents&lt;/span&gt;
vai rerank &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"database performance tuning"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--documents&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"MongoDB Atlas provides a fully managed cloud database"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"Index optimization can improve query performance by 100x"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"Voyage AI offers embedding models for text retrieval"&lt;/span&gt;

&lt;span class="c"&gt;# From a file (JSON array of strings)&lt;/span&gt;
vai rerank &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"best database"&lt;/span&gt; &lt;span class="nt"&gt;--documents-file&lt;/span&gt; candidates.json &lt;span class="nt"&gt;--top-k&lt;/span&gt; 3

&lt;span class="c"&gt;# Lighter model for speed&lt;/span&gt;
vai rerank &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"query"&lt;/span&gt; &lt;span class="nt"&gt;--documents&lt;/span&gt; &lt;span class="s2"&gt;"doc1"&lt;/span&gt; &lt;span class="s2"&gt;"doc2"&lt;/span&gt; &lt;span class="nt"&gt;--model&lt;/span&gt; rerank-2.5-lite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output shows each document with a relevance score from 0 to 1, sorted by relevance. The &lt;code&gt;rerank-2.5&lt;/code&gt; model supports natural language instructions in the query — "Find documents about performance, not pricing" — which lets you steer relevance beyond just semantic similarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When reranking shines:&lt;/strong&gt; RAG pipelines. The quality of an LLM's answer is bounded by the quality of the context you feed it. Retrieve 100 candidates with embedding search, rerank to the top 5, feed those to the LLM. Night and day difference.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai store&lt;/code&gt; — Embed and Insert a Document
&lt;/h3&gt;

&lt;p&gt;One command to embed text and store the result in Atlas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai store &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--text&lt;/span&gt; &lt;span class="s2"&gt;"MongoDB Atlas is a fully managed cloud database"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--metadata&lt;/span&gt; &lt;span class="s1"&gt;'{"title": "Atlas Overview", "category": "product"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sends the text to Voyage AI for embedding&lt;/li&gt;
&lt;li&gt;Inserts a document into &lt;code&gt;myapp.articles&lt;/code&gt; with the original text, the embedding in the &lt;code&gt;embedding&lt;/code&gt; field, and your metadata&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also store from a file or batch from JSONL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# From a file&lt;/span&gt;
vai store &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--file&lt;/span&gt; article.txt

&lt;span class="c"&gt;# Batch from JSONL (one {"text": "...", ...} per line)&lt;/span&gt;
vai store &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--file&lt;/span&gt; documents.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;vai store&lt;/code&gt; is great for individual documents or small batches. For serious bulk work, use &lt;code&gt;vai ingest&lt;/code&gt; (covered below).&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai ingest&lt;/code&gt; — Bulk Import with Progress
&lt;/h3&gt;

&lt;p&gt;This is the "I have 10,000 documents and need them in Atlas Vector Search" command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# JSONL (one JSON object per line, each with a "text" field)&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; corpus.jsonl &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding

&lt;span class="c"&gt;# JSON array&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; documents.json &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding

&lt;span class="c"&gt;# CSV (specify which column to embed)&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; data.csv &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--text-column&lt;/span&gt; content

&lt;span class="c"&gt;# Plain text (one document per line)&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; lines.txt &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;vai ingest&lt;/code&gt; auto-detects the file format from the extension (or content). It splits documents into batches (default 50, max 128 per Voyage API limits), embeds each batch in a single API call, and inserts via &lt;code&gt;insertMany&lt;/code&gt;. You get a real-time progress bar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ████████████░░░░░░░░ 600/1000 (60%) | Batch 12/20 | 3,421 tokens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a summary on completion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ✓ Ingested 1000 documents into myapp.articles
    Batches:    20
    Tokens:     17,234
    Model:      voyage-4-large
    Duration:   12.3s
    Rate:       81.3 docs/sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dry run&lt;/strong&gt; validates your file without spending API credits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; corpus.jsonl &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This parses the file, counts documents, estimates tokens, and reports stats — without calling the API or touching MongoDB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key options:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--batch-size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;Documents per API call (max 128)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--model&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;voyage-4-large&lt;/td&gt;
&lt;td&gt;Embedding model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--input-type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;document&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;query&lt;/code&gt; or &lt;code&gt;document&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--dimensions&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1024&lt;/td&gt;
&lt;td&gt;Output dimensions (256–2048)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--text-field&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;text&lt;/td&gt;
&lt;td&gt;JSON field containing the text to embed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--text-column&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;CSV column to embed (required for CSV)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--strict&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;Abort on first batch error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--dry-run&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;Validate only, no API calls&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For JSONL and JSON inputs, all fields from the source document are preserved — the embedding gets added alongside your existing data. For CSV, every column becomes a document field.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai search&lt;/code&gt; — Vector Similarity Search
&lt;/h3&gt;

&lt;p&gt;Query Atlas Vector Search from the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai search &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"how to optimize database queries"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index&lt;/span&gt; article_search &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--limit&lt;/span&gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query: "how to optimize database queries"
Results: 3

── Result 1 (score: 0.7430) ──
  Index optimization can improve query performance by 100x
  _id: 6981d51c4be7fb9a8e224548

── Result 2 (score: 0.6967) ──
  MongoDB Atlas is a fully managed cloud database service
  _id: 6981d51a5401362b217ce83a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pre-filters&lt;/strong&gt; let you scope the search before the vector comparison happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai search &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"performance"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index&lt;/span&gt; article_search &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="s1"&gt;'{"category": "guides"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is powerful for multi-tenant applications — filter by &lt;code&gt;tenantId&lt;/code&gt; so users only see their own data, then vector-search within that subset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# JSON for scripting&lt;/span&gt;
vai search &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"test"&lt;/span&gt; &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index&lt;/span&gt; article_search &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--json&lt;/span&gt; | jq &lt;span class="s1"&gt;'.[0].score'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;code&gt;vai similarity&lt;/code&gt; — Compare Texts Directly
&lt;/h3&gt;

&lt;p&gt;Sometimes you just want to know how similar two texts are without touching a database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Two texts&lt;/span&gt;
vai similarity &lt;span class="s2"&gt;"MongoDB is a document database"&lt;/span&gt; &lt;span class="s2"&gt;"MongoDB Atlas is a cloud database"&lt;/span&gt;

&lt;span class="c"&gt;# One text against many&lt;/span&gt;
vai similarity &lt;span class="s2"&gt;"database performance"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--against&lt;/span&gt; &lt;span class="s2"&gt;"MongoDB is fast"&lt;/span&gt; &lt;span class="s2"&gt;"PostgreSQL is relational"&lt;/span&gt; &lt;span class="s2"&gt;"Redis is an in-memory store"&lt;/span&gt;

&lt;span class="c"&gt;# From files&lt;/span&gt;
vai similarity &lt;span class="nt"&gt;--file1&lt;/span&gt; doc1.txt &lt;span class="nt"&gt;--file2&lt;/span&gt; doc2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returns cosine similarity scores (0 to 1). Useful for sanity-checking embeddings, comparing document versions, or quick clustering experiments.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai index&lt;/code&gt; — Manage Atlas Vector Search Indexes
&lt;/h3&gt;

&lt;p&gt;Create, list, and delete vector search indexes without leaving the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create an index&lt;/span&gt;
vai index create &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--dimensions&lt;/span&gt; 1024 &lt;span class="nt"&gt;--similarity&lt;/span&gt; cosine &lt;span class="nt"&gt;--index-name&lt;/span&gt; article_search

&lt;span class="c"&gt;# List indexes on a collection&lt;/span&gt;
vai index list &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles

&lt;span class="c"&gt;# Delete an index&lt;/span&gt;
vai index delete &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--index-name&lt;/span&gt; article_search
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Similarity functions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cosine&lt;/code&gt; — Best default for text embeddings. Measures direction, ignores magnitude.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dotProduct&lt;/code&gt; — Equivalent to cosine for normalized vectors. Slightly faster on some hardware.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;euclidean&lt;/code&gt; — Measures straight-line distance. Better for spatial data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New indexes take about 60 seconds to build on small collections. The &lt;code&gt;vai demo&lt;/code&gt; command handles this wait for you automatically.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai models&lt;/code&gt; — List Available Models
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# All models&lt;/span&gt;
vai models

&lt;span class="c"&gt;# Just embedding models&lt;/span&gt;
vai models &lt;span class="nt"&gt;--type&lt;/span&gt; embedding

&lt;span class="c"&gt;# Just rerankers&lt;/span&gt;
vai models &lt;span class="nt"&gt;--type&lt;/span&gt; reranking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quick reference:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Dimensions&lt;/th&gt;
&lt;th&gt;$/1M tokens&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;voyage-4-large&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024 (256–2048)&lt;/td&gt;
&lt;td&gt;$0.12&lt;/td&gt;
&lt;td&gt;Best quality&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-4&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024 (256–2048)&lt;/td&gt;
&lt;td&gt;$0.06&lt;/td&gt;
&lt;td&gt;Balanced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-4-lite&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024 (256–2048)&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;Budget / query-time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-code-3&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024 (256–2048)&lt;/td&gt;
&lt;td&gt;$0.18&lt;/td&gt;
&lt;td&gt;Code search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-finance-2&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024&lt;/td&gt;
&lt;td&gt;$0.12&lt;/td&gt;
&lt;td&gt;Financial text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-law-2&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024&lt;/td&gt;
&lt;td&gt;$0.12&lt;/td&gt;
&lt;td&gt;Legal documents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;voyage-multimodal-3.5&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;1024 (256–2048)&lt;/td&gt;
&lt;td&gt;$0.12 + pixels&lt;/td&gt;
&lt;td&gt;Text + images&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rerank-2.5&lt;/td&gt;
&lt;td&gt;reranking&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;$0.05&lt;/td&gt;
&lt;td&gt;Best reranking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rerank-2.5-lite&lt;/td&gt;
&lt;td&gt;reranking&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;Fast reranking&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Free tier:&lt;/strong&gt; 200M tokens across most models, no credit card required. That's roughly 150,000 pages of text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost optimization trick:&lt;/strong&gt; All Voyage 4 series models share the same embedding space. Embed your documents once with &lt;code&gt;voyage-4-large&lt;/code&gt; for maximum quality, then use &lt;code&gt;voyage-4-lite&lt;/code&gt; at query time (6× cheaper) with no degradation in search accuracy.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai ping&lt;/code&gt; — Test Connectivity
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checks the Voyage AI API (and MongoDB if &lt;code&gt;MONGODB_URI&lt;/code&gt; is set). Shows green checkmarks or red X's with error details. Always start here when debugging.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Machine-readable&lt;/span&gt;
vai ping &lt;span class="nt"&gt;--json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;code&gt;vai config&lt;/code&gt; — Manage Persistent Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Set values (stored in ~/.vai/config.json, chmod 600)&lt;/span&gt;
vai config &lt;span class="nb"&gt;set &lt;/span&gt;api-key &lt;span class="s2"&gt;"pa-your-key"&lt;/span&gt;
vai config &lt;span class="nb"&gt;set &lt;/span&gt;mongodb-uri &lt;span class="s2"&gt;"mongodb+srv://..."&lt;/span&gt;
vai config &lt;span class="nb"&gt;set &lt;/span&gt;base-url &lt;span class="s2"&gt;"https://ai.mongodb.com/v1/"&lt;/span&gt;

&lt;span class="c"&gt;# Secure input (avoids shell history)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"pa-your-key"&lt;/span&gt; | vai config &lt;span class="nb"&gt;set &lt;/span&gt;api-key &lt;span class="nt"&gt;--stdin&lt;/span&gt;

&lt;span class="c"&gt;# View current config (secrets masked)&lt;/span&gt;
vai config get

&lt;span class="c"&gt;# Remove a value&lt;/span&gt;
vai config delete api-key

&lt;span class="c"&gt;# Show config file path&lt;/span&gt;
vai config path

&lt;span class="c"&gt;# Reset everything&lt;/span&gt;
vai config reset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The config file is plaintext (like &lt;code&gt;~/.aws/credentials&lt;/code&gt; or &lt;code&gt;~/.npmrc&lt;/code&gt;). Permissions are set to 600 (owner read/write only) on creation.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai demo&lt;/code&gt; — Interactive Walkthrough
&lt;/h3&gt;

&lt;p&gt;New to vector search? &lt;code&gt;vai demo&lt;/code&gt; runs a guided 5-step walkthrough: embed text, store documents, create an index, run a search, and rerank results. It uses a temporary collection and cleans up after itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai demo

&lt;span class="c"&gt;# Non-interactive (no pauses between steps)&lt;/span&gt;
vai demo &lt;span class="nt"&gt;--no-pause&lt;/span&gt;

&lt;span class="c"&gt;# Skip the full pipeline if you just want to see embed + rerank&lt;/span&gt;
vai demo &lt;span class="nt"&gt;--skip-pipeline&lt;/span&gt;

&lt;span class="c"&gt;# Keep the demo data afterward&lt;/span&gt;
vai demo &lt;span class="nt"&gt;--keep&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great for onboarding, workshops, or just getting a feel for the tool.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai explain&lt;/code&gt; — Built-in Learning
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai explain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lists 12 educational topics you can read right in the terminal:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;What you'll learn&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;embeddings&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What vectors are and how they encode meaning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;reranking&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Why cross-attention beats independent encoding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vector-search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How Atlas &lt;code&gt;$vectorSearch&lt;/code&gt; works under the hood&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rag&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieval-Augmented Generation patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cosine-similarity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Measuring vector distance (cosine vs dot product vs euclidean)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;two-stage-retrieval&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The embed → search → rerank pipeline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;input-type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Why &lt;code&gt;query&lt;/code&gt; vs &lt;code&gt;document&lt;/code&gt; matters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;models&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Choosing the right model for your use case&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api-keys&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creating and managing Model API keys in Atlas&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;api-access&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MongoDB Atlas vs. Voyage AI platform endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;batch-processing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Strategies for embedding large datasets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;benchmarking&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How to choose the right model for your use case&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai explain rag
vai explain two-stage-retrieval
vai explain api-access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each topic includes explanations, key points, try-it commands, and links to official docs. Aliases work too — &lt;code&gt;vai explain auth&lt;/code&gt;, &lt;code&gt;vai explain cosine&lt;/code&gt;, &lt;code&gt;vai explain vectors&lt;/code&gt; all resolve correctly.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai benchmark&lt;/code&gt; — Choose the Right Model
&lt;/h3&gt;

&lt;p&gt;Picking between &lt;code&gt;voyage-4-large&lt;/code&gt;, &lt;code&gt;voyage-4&lt;/code&gt;, and &lt;code&gt;voyage-4-lite&lt;/code&gt; isn't obvious from a spec sheet. &lt;code&gt;vai benchmark&lt;/code&gt; lets you test with real API calls on your actual data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Compare embedding model latency (default: 3 models × 5 rounds)&lt;/span&gt;
vai benchmark embed

&lt;span class="c"&gt;# Custom text, specific models&lt;/span&gt;
vai benchmark embed &lt;span class="nt"&gt;--models&lt;/span&gt; voyage-4-large,voyage-4-lite &lt;span class="nt"&gt;--rounds&lt;/span&gt; 3 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--input&lt;/span&gt; &lt;span class="s2"&gt;"your domain-specific text here"&lt;/span&gt;

&lt;span class="c"&gt;# Compare reranking models with ranking quality analysis&lt;/span&gt;
vai benchmark rerank &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"how to scale a database"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--documents-file&lt;/span&gt; candidates.json

&lt;span class="c"&gt;# See if expensive and cheap models rank your data the same&lt;/span&gt;
vai benchmark similarity &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"your search query"&lt;/span&gt; &lt;span class="nt"&gt;--file&lt;/span&gt; corpus.txt

&lt;span class="c"&gt;# Project monthly costs at scale&lt;/span&gt;
vai benchmark cost &lt;span class="nt"&gt;--tokens&lt;/span&gt; 500 &lt;span class="nt"&gt;--volumes&lt;/span&gt; 100,1000,10000,100000

&lt;span class="c"&gt;# Find optimal batch size for ingestion pipelines&lt;/span&gt;
vai benchmark batch &lt;span class="nt"&gt;--batch-sizes&lt;/span&gt; 1,5,10,25,50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The latency benchmark gives you avg/p50/p95 timings, token counts, and cost per model — with a ⚡ badge on the fastest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Model                    Avg      p50      p95   Dims  Tokens  $/1M tok
  ──────────────────────────────────────────────────────────────────────
  voyage-4-lite          174ms    167ms    207ms   1024       7     $0.02 ⚡
  voyage-4               181ms    172ms    216ms   1024       7     $0.06
  voyage-4-large         256ms    262ms    355ms   1024       7     $0.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ranking comparison tells you whether the cheaper model is &lt;em&gt;actually&lt;/em&gt; good enough for your data — it embeds a query + corpus with each model and shows side-by-side top-K rankings. If the models agree, save your money. If they diverge, the premium model is catching nuance the lite one misses.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;--save&lt;/code&gt; to export results to JSON and track performance over time. Use &lt;code&gt;--json&lt;/code&gt; for CI integration.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai playground&lt;/code&gt; — Interactive Web UI
&lt;/h3&gt;

&lt;p&gt;Not everyone lives in the terminal. &lt;code&gt;vai playground&lt;/code&gt; launches a local web UI at &lt;code&gt;http://localhost:3333&lt;/code&gt; with everything you can do from the CLI, plus visual tools you can't:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai playground
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaulg9wg9xz4nalca0gy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaulg9wg9xz4nalca0gy.png" alt="playground" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Five tabs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;⚡ Embed&lt;/strong&gt; — Paste text, pick a model, see the vector and a heatmap visualization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⚖️ Compare&lt;/strong&gt; — Enter two texts and get a big cosine similarity score with a visual bar&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🔍 Search&lt;/strong&gt; — Semantic search with optional reranking, side-by-side result comparison&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⏱ Benchmark&lt;/strong&gt; — Visual latency bars, ranking comparisons, interactive cost calculator with sliders, and a history chart of past runs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📚 Explore&lt;/strong&gt; — All 12 educational topics from &lt;code&gt;vai explain&lt;/code&gt;, searchable, with links and try-it examples&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The benchmark tab is particularly useful — drag the "queries per day" slider to 100K and watch the cost table update live. It makes the price/performance tradeoff visceral in a way that numbers on a screen don't.&lt;/p&gt;

&lt;p&gt;The playground runs entirely locally. Your API key never leaves your machine. No data is sent anywhere except the Voyage AI API for actual embedding/reranking calls.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;vai about&lt;/code&gt; — Who Built This
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vai about
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows project info, author details, feature list, and the community disclaimer. Also available as the &lt;strong&gt;ℹ️ About&lt;/strong&gt; tab in the playground, complete with a proper avatar and links.&lt;/p&gt;




&lt;h2&gt;
  
  
  Full Pipeline: Start to Finish
&lt;/h2&gt;

&lt;p&gt;Here's the whole thing, start to finish. Five minutes to a working semantic search system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Set credentials&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;VOYAGE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"pa-your-key"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;MONGODB_URI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mongodb+srv://user:pass@cluster.mongodb.net/"&lt;/span&gt;

&lt;span class="c"&gt;# 2. Verify connectivity&lt;/span&gt;
vai ping

&lt;span class="c"&gt;# 3. Bulk-ingest a corpus&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; articles.jsonl &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--model&lt;/span&gt; voyage-4-large &lt;span class="nt"&gt;--input-type&lt;/span&gt; document

&lt;span class="c"&gt;# 4. Create a vector search index&lt;/span&gt;
vai index create &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--dimensions&lt;/span&gt; 1024 &lt;span class="nt"&gt;--similarity&lt;/span&gt; cosine &lt;span class="nt"&gt;--index-name&lt;/span&gt; article_search

&lt;span class="c"&gt;# 5. Wait ~60s for the index to build, then search&lt;/span&gt;
vai search &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"how to scale a database"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index&lt;/span&gt; article_search &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--limit&lt;/span&gt; 10

&lt;span class="c"&gt;# 6. Rerank the top results for precision&lt;/span&gt;
vai rerank &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"how to scale a database"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--documents-file&lt;/span&gt; top_results.json &lt;span class="nt"&gt;--top-k&lt;/span&gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't have a corpus handy, &lt;code&gt;vai demo&lt;/code&gt; builds one for you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scripting and Automation
&lt;/h2&gt;

&lt;p&gt;Every command supports &lt;code&gt;--json&lt;/code&gt; for machine-readable output and &lt;code&gt;--quiet&lt;/code&gt; to suppress spinners and decorative output. This makes &lt;code&gt;vai&lt;/code&gt; composable with &lt;code&gt;jq&lt;/code&gt;, shell scripts, and CI pipelines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Embed and extract just the vector&lt;/span&gt;
&lt;span class="nv"&gt;VECTOR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;vai embed &lt;span class="s2"&gt;"test query"&lt;/span&gt; &lt;span class="nt"&gt;--json&lt;/span&gt; | jq &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'.data[0].embedding'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Search and get the top score&lt;/span&gt;
vai search &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"test"&lt;/span&gt; &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--index&lt;/span&gt; article_search &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--json&lt;/span&gt; | jq &lt;span class="s1"&gt;'.[0].score'&lt;/span&gt;

&lt;span class="c"&gt;# Dry-run ingest in CI to validate data format&lt;/span&gt;
vai ingest &lt;span class="nt"&gt;--file&lt;/span&gt; data.jsonl &lt;span class="nt"&gt;--db&lt;/span&gt; myapp &lt;span class="nt"&gt;--collection&lt;/span&gt; articles &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--field&lt;/span&gt; embedding &lt;span class="nt"&gt;--dry-run&lt;/span&gt; &lt;span class="nt"&gt;--json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What I Didn't Build (Yet)
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;vai&lt;/code&gt; is pretty spartan at the moment - I haven't spent much time on it.  Here's a few things on the roadmap... if you have suggestions, I'm all ears:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multimodal embedding&lt;/strong&gt; — &lt;code&gt;voyage-multimodal-3.5&lt;/code&gt; can embed images and text in the same space. The API endpoint for this isn't live on &lt;code&gt;ai.mongodb.com/v1&lt;/code&gt; yet, but when it is, &lt;code&gt;vai&lt;/code&gt; will support it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contextualized chunks&lt;/strong&gt; — &lt;code&gt;voyage-context-3&lt;/code&gt; embeds chunks while considering the surrounding document. Same story — waiting on the endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid search&lt;/strong&gt; — Combine vector search with Atlas full-text search for the best of both worlds.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Repository
&lt;/h2&gt;

&lt;p&gt;Please fork, star, clone, open issues, let me know what you think. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;code&gt;npm install -g voyageai-cli&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/mrlynn/voyageai-cli" rel="noopener noreferrer"&gt;github.com/mrlynn/voyageai-cli&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;193 tests. CI on Node 18 and 20. Contributions welcome.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Michael Lynn is a Principal Staff Developer Advocate at MongoDB. &lt;code&gt;vai&lt;/code&gt; is an independent community tool — not an official MongoDB or Voyage AI product.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" alt="" width="1" height="1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftrwr.link%2FkPdAwENK" width="1" height="1"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>ai</category>
      <category>vectorsearch</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
