# gemini-Embedding-2

Source: https://zilliz.com/ai-models/gemini-embedding-2
Published: 2026-03-18T09:03:42.204Z

## Model attributes

| Attribute | Value |
| --- | --- |
| Provider | Google |
| Integration | 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](https://github.com/milvus-io/pymilvus)**: the Python SDK for [Milvus](https://zilliz.com/what-is-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](https://zilliz.com/cloud) (a fully managed vector database service powered by Milvus) and used for [semantic similarity search](https://zilliz.com/glossary/semantic-search). Here are four key steps:

1.  [Sign up](https://cloud.zilliz.com/signup) for a Zilliz Cloud account for free.
2.  [Set up a serverless cluster](https://docs.zilliz.com/docs/create-cluster#set-up-a-free-cluster) and obtain the [Public Endpoint and API Key](https://docs.zilliz.com/docs/byoc/quick-start#free-cluster-details).
3.  **Create a vector collection** and insert your vector embeddings.
4.  **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](https://ai.google.dev/gemini-api/docs/embeddings).
