Gemini Embedding 2

Build agents
HoneyHive Engineering

Gemini Embedding 2 maps text, images, video, audio and PDFs into one vector space: its dimensions, limits, task prefixes, pricing and migration pitfalls.

Gemini Embedding 2 (gemini-embedding-2) is the Gemini API’s first multimodal embedding model. Google’s embeddings guide says it maps text, images, video, audio and documents into one embedding space, which allows cross-modal search, classification and clustering across over 100 languages. A text query can retrieve an image or a PDF page because all of them land in the same vectors.

This page covers the model itself. For how to pick between embedding models, see embedding models; for scoring with the vectors, see semantic similarity.

Specs at a glance

Property Value
Model code gemini-embedding-2, per the model page
Input Text, image, video, audio and PDF, per the model page
Output A text embedding vector. The default is 3072 dimensions
Dimensions Flexible from 128 to 3072, with 768, 1536 and 3072 recommended
Input limit 8,192 tokens overall
Status Stable. The model page lists the latest update as April 2026, and the changelog says it reached general availability on April 22, 2026

Modalities and limits

The guide’s limits table sets per-request caps:

Input Limit
Text Up to 8,192 tokens
Image Up to 6 images per request. PNG and JPEG
Audio Up to 180 seconds. MP3 and WAV
Video Up to 120 seconds. MP4 and MOV, with H264, H265, AV1 or VP9 codecs
PDF 1 file per request, up to 6 pages

For video, Google says the system processes at most 32 frames: videos of 32 seconds or less are sampled at 1 frame per second, and longer ones are sampled uniformly down to 32 frames. Audio tracks inside video files are not processed. If you need the speech in a video, extract it and embed it as audio.

Anything longer than these caps has to be split first. The 8,192-token limit is shared across all modalities, and Google says inputs over it are silently truncated. For PDFs it strongly recommends 1 page per file for the best quality. Splitting text follows the usual chunking strategies; for a long PDF, that means batches of pages.

Basic call

Google’s quickstart uses embedContent:

from google import genai

client = genai.Client()

result = client.models.embed_content(
        model="gemini-embedding-2",
        contents="What is the meaning of life?"
)

print(result.embeddings)

One embedding or many

This is the behavior change most likely to bite. A note in the guide says that gemini-embedding-001 returns an embedding per string in a list, while Gemini Embedding 2 produces a single aggregated embedding for multiple inputs. The docs describe three patterns:

  • Several parts passed directly in contents give one aggregated embedding for all of them.
  • Each input wrapped in its own Content object gives a separate embedding per entry.
  • For an object such as a social post with several media items, Google recommends embedding the pieces separately and aggregating them, for example by averaging.

The Batch API is the other route to many separate embeddings at once. If you pass a list of 100 document chunks as plain parts and expect 100 vectors, you will get one.

Task types are now prompt prefixes

With gemini-embedding-001 you set a task_type such as RETRIEVAL_DOCUMENT. Google’s guide says the field cannot be used with gemini-embedding-2. For text-only tasks it strongly recommends putting the task instruction in the text itself:

Use case Query Document
Search query task: search result | query: {content} title: {title} | text: {content} (use title: none without a title)
Question answering task: question answering | query: {content} title: {title} | text: {content}
Fact checking task: fact checking | query: {content} title: {title} | text: {content}
Code retrieval task: code retrieval | query: {content} title: {title} | text: {content}

Symmetric tasks use one format for both sides: task: classification | query: {content}, task: clustering | query: {content} and task: sentence similarity | query: {content}. Google warns that the sentence similarity format is for semantic textual similarity and should not be used for search or retrieval.

Two rules from the docs:

  • Use the task format consistently. If documents are embedded with the classification format, the queries must be too.
  • When one embedding comes from multimodal input, Google generally does not recommend prefixing the text part. It says a prefix helps in some cases and hurts in others, so test it on your data.

Choosing a dimension

Both gemini-embedding-001 and gemini-embedding-2 are trained with Matryoshka Representation Learning, so a prefix of the vector is still a useful embedding. Set output_dimensionality to shorten it:

config=types.EmbedContentConfig(output_dimensionality=768)

Google publishes MTEB scores by size, without saying which of its two models they come from, and notes that quality is not strictly tied to dimension:

Dimensions MTEB score
2048 68.16
1536 68.17
768 67.99
512 67.55
256 66.19
128 63.31

The table is Google’s, and it does not list 3072. Use it as a guide to the shape of the trade-off, then measure retrieval on your own queries before cutting storage. See embedding models for how to run that test.

Normalization differs by model. Gemini Embedding 2 automatically normalizes vectors shortened below 3072 dimensions. With gemini-embedding-001 you had to normalize non-3072 vectors yourself, so code carried over from that model does not need the extra step here.

Pricing

Google’s model page lists these paid-tier prices per 1 million tokens in USD, as of November 2026. Prices change, so confirm them before budgeting.

Input Standard Batch
Text $0.20 $0.10
Image $0.45 ($0.00012 per image) $0.225 ($0.00006 per image)
Audio $6.50 ($0.00016 per second) $3.25 ($0.00008 per second)
Video $12.00 ($0.00079 per frame) $6.00 ($0.000395 per frame)

The standard tier has a free tier, which the page says is used to improve Google’s products. The paid tier is not. The batch tier has no free option. Google’s guide says the Batch API gives much higher throughput at 50% of the default price, which matches the table. Audio and video cost far more per token than text, so a media-heavy corpus is where the bill concentrates.

Migrating

Two separate moves are easy to confuse.

From gemini-embedding-2-preview. Google’s changelog marks the preview model as deprecated and says that from November 6, 2026, requests to it route to gemini-embedding-2, with the same API schema, pricing and embedding space. The entry says no other code changes or vector re-indexing are needed. Changing the model string to gemini-embedding-2 is still the clean fix, since a routed name is a name Google can retire.

From gemini-embedding-001. This one is a real migration. The guide says the embedding spaces are incompatible, so you cannot compare vectors across the two models and must re-embed all existing data. A checklist drawn from the docs:

  1. Re-embed the whole corpus, since vectors from the two models cannot be compared.
  2. Replace task_type with the prompt prefixes above.
  3. Check any call that passes a list, because it now returns one aggregated embedding unless you wrap each item in a Content object or use the Batch API.
  4. Drop manual normalization for shortened vectors.

Google also says gemini-embedding-001 remains available for text-only use cases, so staying on it is a valid choice if you do not need other modalities.

Common pitfalls

  • Mixing vectors from two models in one index. Similarity scores between them are meaningless.
  • Missing or inconsistent prefixes. Documents embedded with one task format and queries with another degrade retrieval.
  • Expecting a vector per list item. See the aggregation section.
  • Exceeding per-request caps. 6 images, 180 seconds of audio, 120 seconds of video and 6 PDF pages per request.
  • Assuming video audio is searchable. The audio track is not processed.
  • Choosing a dimension by guess. Test 768 against 3072 on real queries.

Where it fits in a retrieval stack

Embeddings are the first stage of semantic search and a RAG pipeline. Google lists retrieval-augmented generation, information retrieval, search reranking, anomaly detection, classification and clustering as use cases. Pairing vector search with keyword search is covered in hybrid search, and a model that reorders the top results is covered in reranking. To judge whether a change of embedding model helped, use a golden dataset and the metrics in RAG evaluation.

Tracing embedding calls in HoneyHive

HoneyHive’s Gemini integration guide says it traces Gemini chat, embeddings and multimodal requests with OpenInference. HoneyHive’s multi-modal tracing guide advises storing references such as paths, URLs or IDs instead of raw media bytes. That fits an embedding pipeline over images, audio or video: log which model and prefix produced each vector, so a retrieval regression after a migration can be traced to its cause.

FAQ

What is Gemini Embedding 2?

It is Google's first multimodal embedding model in the Gemini API. Google's docs say it maps text, images, video, audio and documents into a unified embedding space, with support for over 100 languages. The model code is gemini-embedding-2.

How many dimensions does Gemini Embedding 2 output?

3072 by default. The model page says any size from 128 to 3072 is supported and recommends 768, 1536 or 3072. Set output_dimensionality to shorten the vector.

Can I mix Gemini Embedding 2 and gemini-embedding-001 vectors?

No. Google's migration notes say the two embedding spaces are incompatible, so moving to Gemini Embedding 2 means re-embedding all existing data.

Does Gemini Embedding 2 support task_type?

No. The embeddings guide says the task_type field cannot be used with it. For text, put the task in the prompt, for example task: search result | query: {content}.

What happened to gemini-embedding-2-preview?

Google's changelog says requests to it route to gemini-embedding-2 from November 6, 2026, and that no other code changes or vector re-indexing are needed. Update the model string anyway.

Share