Model chooser  /  Search and answer from your own content  /  Recurring

For search over your content, embed it with Gemini Embedding 2.

A help-centre assistant or internal search runs thousands of queries against content that changes. That needs embeddings. Gemini Embedding 2 embeds text, images, video, audio and PDF into one space, with adjustable dimensions and a low price per token.

Why Gemini Embedding 2

The reasons it wins for this job.

  • It embeds text, image, video, audio and PDF into the same vector space, so one index can search slides, recordings and docs together.
  • Output dimensions are adjustable from 128 to 3072. Google recommends 768, 1536 or 3072; smaller vectors cut database cost for large corpora.
  • It is priced per token in the low cost tier and runs on the same API key as Gemini's text models.
  • It takes task hints in the input text itself, so query and document embeddings can be tuned without a separate parameter.

How to use it

4 steps to a first result.

  1. 1Chunk by meaningSplit docs at headings, 300 to 800 tokens each, and keep the title and URL with every chunk.
  2. 2Embed and storeEmbed each chunk and store vector plus metadata in your database (pgvector, Pinecone, Turbopuffer).
  3. 3Retrieve, rerank, answerFetch the top 20, rerank to the best 5, and send those to your chat model with instructions to cite.
  4. 4Re-embed on changeHook into your CMS so edited pages are re-embedded the same day.

Gemini API, TypeScript

Start from this.

Edit the parts in capitals, then run it.

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({}); // reads GEMINI_API_KEY

export async function embed(text: string, kind: "query" | "document") {
  const res = await ai.models.embedContent({
    model: "gemini-embedding-2",
    // gemini-embedding-2 takes the task hint in the text, not a task_type parameter
    contents: kind === "query" ? `Search query: ${text}` : `Document: ${text}`,
    config: { outputDimensionality: 768 },
  });
  return res.embeddings[0].values; // number[] of length 768
}
Nothing is sent anywhere. It copies to your clipboard.

Alternatives that also work

If Gemini Embedding 2 is not an option.

Voyage 4 LargeOfficial page →

Voyage AI (MongoDB) · closed · cost: low

Pick it when search quality is the priority, including multilingual and code. Voyage calls it its best general-purpose model, with a 32K context.

NVIDIA Nemotron 3 Embed 8BHugging Face →

NVIDIA · open weights · cost: free weights; you pay for the hardware · 111K HF downloads/mo

Pick it when you self-host. NVIDIA reports first place on the RTEB retrieval leaderboard in July 2026, with a commercial-use license.

OpenAI text-embedding-3-largeOfficial page →

OpenAI · closed · cost: low

Pick it when you are already on OpenAI and the index is text only.

Watch out for

Doing this just once? To ask questions of your content once, skip the index and use Gemini 3.8 Flash. For a one-off question across a folder of docs, recordings or slides, you do not need embeddings at all. Put everything into a 1M-token context and ask. Gemini 3.8 Flash reads text, PDF, images, audio and video in one request.

Sources

Checked . Models change monthly; we re-check this page when they do.

Picking the model is the easy part.

Wiring it into a workflow that runs every week, with evals, fallbacks and a cost you can predict, is the work. Fifteen minutes, no deck.

Book fifteen minutes →