Google / gemini-Embedding-2
Milvus Integrated
Task: Embedding
Modality: Multimodal
Similarity Metric: Cosine
License: Proprietary
Dimensions: 3072
Max Input Tokens: 8192
Price: $0.20 / 1M text tokens
Introduction to the gemini-embedding-2 Model
gemini-embedding-2-preview is Google's first natively multimodal embedding model that creates embeddings with up to 3072 dimensions. Compared to Google's other embedding models, like text-embedding-004 and gemini-embedding-exp-03-07, Gemini Embedding 2 supports multiple modalities — text, images, videos, audio, and documents — in a unified embedding space across 100+ languages, making it ideal for multimodal RAG and semantic search applications.
Let's take a quick look at some basics.
| Model | Dimensions | Max Tokens | Languages | Price |
|---|---|---|---|---|
| gemini-embedding-2-preview | 3072 (supports MRL) | 8,192 | 100+ | $0.20 / 1M text tokens |
| gemini-embedding-exp-03-07 | 3072 (supports MRL) | 8,192 | Multilingual | $0.15 / 1M tokens |
| text-embedding-004 | 768 | 2,048 | English | $0.025 / 1M chars |
How to Use the gemini-embedding-2 Model
There are two primary ways to use Gemini Embedding 2 to generate vector embeddings:
- PyMilvus: the Python SDK for Milvus that seamlessly integrates the Gemini Embedding 2 model.
- Google Gemini API: the Python SDK offered by Google (
google-genai).
These methods allow developers to easily incorporate advanced multimodal embedding capabilities into their applications.
Once the vector embeddings are generated, they can be stored in Zilliz Cloud (a fully managed vector database service powered by Milvus) and used for semantic similarity search. Here are four key steps:
- Sign up for a Zilliz Cloud account for free.
- Set up a serverless cluster and obtain the Public Endpoint and API Key.
- Create a vector collection and insert your vector embeddings.
- Run a semantic search on the stored embeddings.
Generate embeddings via Google Gemini API and insert them into Zilliz Cloud for semantic search
from google import genai
from pymilvus import MilvusClient
GEMINI_API_KEY = "your-gemini-api-key"
gemini_client = genai.Client(api_key=GEMINI_API_KEY)
# Generate embeddings for documents
docs = [
"Artificial intelligence was founded as an academic discipline in 1956.",
"Alan Turing was the first person to conduct substantial research in AI.",
"Born in Maida Vale, London, Turing was raised in southern England.",
]
doc_result = gemini_client.models.embed_content(
model="gemini-embedding-2-preview",
contents=docs,
)
doc_embeddings = [e.values for e in doc_result.embeddings]
# Generate embeddings for queries
queries = ["When was artificial intelligence founded",
"Where was Alan Turing born?"]
query_result = gemini_client.models.embed_content(
model="gemini-embedding-2-preview",
contents=queries,
)
query_embeddings = [e.values for e in query_result.embeddings]
# Connect to Zilliz Cloud with Public Endpoint and API Key
milvus_client = MilvusClient(
uri=ZILLIZ_PUBLIC_ENDPOINT,
token=ZILLIZ_API_KEY)
COLLECTION = "documents"
if milvus_client.has_collection(collection_name=COLLECTION):
milvus_client.drop_collection(collection_name=COLLECTION)
milvus_client.create_collection(
collection_name=COLLECTION,
dimension=3072,
auto_id=True)
for doc, embedding in zip(docs, doc_embeddings):
milvus_client.insert(COLLECTION, {"text": doc, "vector": embedding})
results = milvus_client.search(
collection_name=COLLECTION,
data=query_embeddings,
output_fields=["text"])
For more information, refer to Google's Gemini Embedding Guide.
Seamless AI Workflows
From embeddings to scalable AI search—Zilliz Cloud lets you store, index, and retrieve embeddings with unmatched speed and efficiency.
Try Zilliz Cloud for Free

