> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Embedding 2 (gemini-embedding-2)

> Google's Gemini Embedding 2 embeds text for the task you choose, such as search or clustering, and works with integrated embedding on document indexes.

[Back to all models](https://docs.pinecone.io/models/overview.md)

![Google](https://cdn.sanity.io/images/vr8gru94/production/2cc789a02534557380d92124e2f8b9483d198fb3-24x24.svg)

# gemini-embedding-2

Google

Hosted by Pinecone
Builder plan and above

Specifications

<dl />

## When to use it

[Gemini Embedding 2](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/embedding-2) (`gemini-embedding-2`) is a dense text embedding model from Google. Pinecone offers it for [integrated embedding](https://docs.pinecone.io/guides/search/integrated-embedding.md#embed-with-gemini-embedding-2) on document indexes, so you upsert and search with text and Pinecone embeds it through Google Vertex AI.

The model embeds text differently for each [task](#task-types) you choose with `task_type`, such as `retrieval_document` for stored text, `question_answering` or `fact_verification` for queries, or `clustering` for grouping texts. You can also override the query task for one search.

## Inputs, limits, and pricing

| Input | Limits | Price |
| - | - | - |
| Text | 8192 tokens per input | \$0.20 per 1M tokens |

Monthly and per-minute limits depend on your plan. See [Rate limits](https://docs.pinecone.io/reference/api/database-limits/rate-limits.md#monthly-usage-limits).

## Quickstart

### Installation

Integrated embedding on document indexes requires Python SDK `10.1.0`, Node.js SDK `9.1.0`, or Go SDK `7.1.0` or later.

```shell Python theme={null}
pip install --upgrade pinecone
```

```shell JavaScript theme={null}
npm install @pinecone-database/pinecone
```

```shell Go theme={null}
go get github.com/pinecone-io/go-pinecone/v7/pinecone
```

### Create index

This creates a document index whose `chunk_text` field embeds with `gemini-embedding-2` at 768 dimensions. The field's write task defaults to `retrieval_document`, and its queries default to `retrieval_query`.

```python Python theme={null}
import time
from pinecone import Pinecone, SchemaBuilder

pc = Pinecone(api_key="YOUR_API_KEY")

schema = (
    SchemaBuilder()
      .add_string_field(
          name="chunk_text",
          embed={"model": "gemini-embedding-2", "dimension": 768},
      )
      .build()
)
pc.indexes.create(name="gemini-embedding-2", schema=schema)

while not pc.indexes.describe(name="gemini-embedding-2").status.ready:
    time.sleep(2)

index = pc.index(name="gemini-embedding-2")
```

```javascript JavaScript theme={null}
import { Pinecone } from '@pinecone-database/pinecone';

const pc = new Pinecone({ apiKey: 'YOUR_API_KEY' });

const indexModel = await pc.indexes.create({
  name: 'gemini-embedding-2',
  schema: {
    fields: {
      chunk_text: {
        type: 'string',
        embed: { model: 'gemini-embedding-2', dimension: 768 },
      },
    },
  },
  waitUntilReady: true,
});

const index = pc.index({ host: indexModel.host, namespace: 'example-namespace' });
```

```go Go theme={null}
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/pinecone-io/go-pinecone/v7/pinecone"
)

func main() {
    ctx := context.Background()

    pc, err := pinecone.NewClient(pinecone.NewClientParams{
        ApiKey: "YOUR_API_KEY",
    })
    if err != nil {
        log.Fatalf("Failed to create Client: %v", err)
    }

    model := "gemini-embedding-2"
    dimension := int32(768)
    idx, err := pc.CreateIndex(ctx, &pinecone.CreateIndexRequest{
        Name: "gemini-embedding-2",
        Schema: pinecone.IndexSchema{
            Fields: map[string]pinecone.IndexSchemaField{
                "chunk_text": {
                    String: &pinecone.StringField{
                        Embed: &pinecone.EmbedConfig{Model: &model, Dimension: &dimension},
                    },
                },
            },
        },
    })
    if err != nil {
        log.Fatalf("Failed to create index: %v", err)
    }
    fmt.Printf("Successfully created index: %v", idx.Name)
}
```

```bash curl theme={null}
curl -X POST "https://api.pinecone.io/indexes" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "name": "gemini-embedding-2",
    "schema": {
      "fields": {
        "chunk_text": {
          "type": "string",
          "embed": { "model": "gemini-embedding-2", "dimension": 768 }
        }
      }
    }
  }'
```

### Embed & upsert

Upsert documents with plain text on the embedded field. Pinecone embeds each value on write, up to 96 documents per request.

```python Python theme={null}
index.documents.upsert(
    namespace="example-namespace",
    documents=[
        {"_id": "doc1", "chunk_text": "Apple is a popular fruit known for its sweetness and crisp texture."},
        {"_id": "doc2", "chunk_text": "The tech company Apple is known for its innovative products like the iPhone."},
        {"_id": "doc3", "chunk_text": "Many people enjoy eating apples as a healthy snack."},
        {"_id": "doc4", "chunk_text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
        {"_id": "doc5", "chunk_text": "An apple a day keeps the doctor away, as the saying goes."},
        {"_id": "doc6", "chunk_text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."},
    ],
)
```

```javascript JavaScript theme={null}
await index.documents.upsert({
  documents: [
    { _id: 'doc1', chunk_text: 'Apple is a popular fruit known for its sweetness and crisp texture.' },
    { _id: 'doc2', chunk_text: 'The tech company Apple is known for its innovative products like the iPhone.' },
    { _id: 'doc3', chunk_text: 'Many people enjoy eating apples as a healthy snack.' },
    { _id: 'doc4', chunk_text: 'Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.' },
    { _id: 'doc5', chunk_text: 'An apple a day keeps the doctor away, as the saying goes.' },
    { _id: 'doc6', chunk_text: 'Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership.' },
  ],
});
```

```go Go theme={null}
idx, err := pc.DescribeIndex(ctx, "gemini-embedding-2")
if err != nil {
    log.Fatalf("Failed to describe index: %v", err)
}

idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "example-namespace"})
if err != nil {
    log.Fatalf("Failed to create IndexConnection: %v", err)
}

_, err = idxConnection.UpsertDocuments(ctx, &pinecone.UpsertDocumentsRequest{
    Documents: []pinecone.Document{
        {"_id": "doc1", "chunk_text": "Apple is a popular fruit known for its sweetness and crisp texture."},
        {"_id": "doc2", "chunk_text": "The tech company Apple is known for its innovative products like the iPhone."},
        {"_id": "doc3", "chunk_text": "Many people enjoy eating apples as a healthy snack."},
        {"_id": "doc4", "chunk_text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces."},
        {"_id": "doc5", "chunk_text": "An apple a day keeps the doctor away, as the saying goes."},
        {"_id": "doc6", "chunk_text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership."},
    },
})
if err != nil {
    log.Fatalf("Failed to upsert documents: %v", err)
}
```

```bash curl theme={null}
curl -X POST "https://$INDEX_HOST/namespaces/example-namespace/documents/upsert" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "documents": [
      { "_id": "doc1", "chunk_text": "Apple is a popular fruit known for its sweetness and crisp texture." },
      { "_id": "doc2", "chunk_text": "The tech company Apple is known for its innovative products like the iPhone." },
      { "_id": "doc3", "chunk_text": "Many people enjoy eating apples as a healthy snack." },
      { "_id": "doc4", "chunk_text": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces." },
      { "_id": "doc5", "chunk_text": "An apple a day keeps the doctor away, as the saying goes." },
      { "_id": "doc6", "chunk_text": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership." }
    ]
  }'
```

### Query

Search with an `embed` clause, and Pinecone embeds the query text with the field's read task.

```python Python theme={null}
response = index.documents.search(
    namespace="example-namespace",
    top_k=3,
    score_by=[
        {"type": "embed", "fields": ["chunk_text"], "query": "Tell me about the tech company known as Apple."}
    ],
    include_fields=["chunk_text"],
)

for match in response.matches:
    print(match._id, match._score, match.chunk_text)
```

```javascript JavaScript theme={null}
const response = await index.documents.search({
  topK: 3,
  scoreBy: [
    { type: 'embed', fields: ['chunk_text'], query: 'Tell me about the tech company known as Apple.' },
  ],
  includeFields: ['chunk_text'],
});

console.log(response);
```

```go Go theme={null}
query := "Tell me about the tech company known as Apple."
response, err := idxConnection.SearchDocuments(ctx, &pinecone.SearchDocumentsRequest{
    TopK: 3,
    ScoreBy: []pinecone.DocumentScoringMethod{
        {Type: pinecone.DocumentScoringTypeEmbed, Fields: []string{"chunk_text"}, Query: &query},
    },
    IncludeFields: []string{"chunk_text"},
})
if err != nil {
    log.Fatalf("Failed to search documents: %v", err)
}
fmt.Println(response)
```

```bash curl theme={null}
curl -X POST "https://$INDEX_HOST/namespaces/example-namespace/documents/search" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "top_k": 3,
    "score_by": [
      { "type": "embed", "fields": ["chunk_text"], "query": "Tell me about the tech company known as Apple." }
    ],
    "include_fields": ["chunk_text"]
  }'
```

## Task types

Each task type is a write task, a query task, or a symmetric task. Set the write task in the field's `write_parameters` and the default query task in its `read_parameters`. A symmetric task embeds stored text and queries the same way, for comparing texts with each other rather than searching. For which tasks a field accepts, see [Set task types on the field](https://docs.pinecone.io/guides/search/integrated-embedding.md#set-task-types-on-the-field).

| Task type | Kind | Use it for |
| :- | :- | :- |
| `retrieval_document` | Write | Stored text that you search. This is the default write task. |
| `retrieval_query` | Query | General search queries. This is the default query task for a `retrieval_document` field. |
| `question_answering` | Query | Questions whose answers are in the stored text. |
| `fact_verification` | Query | Statements to check against the stored text. |
| `code_retrieval_query` | Query | Natural-language queries for stored code. |
| `classification` | Symmetric | Texts you sort into labeled categories. |
| `clustering` | Symmetric | Texts you group by similarity. |
| `sentence_similarity` | Symmetric | Texts you compare for semantic similarity. |

### Override the query task

To embed one query with a different task, set `parameters` on the `embed` clause. The Python SDK supports `parameters` in `10.3.0` and later. The Node.js and Go SDKs don't support it yet, so use the REST API with them. This search embeds its query as a question with `question_answering`:

```python Python theme={null}
response = index.documents.search(
    namespace="example-namespace",
    top_k=3,
    score_by=[
        {
            "type": "embed",
            "fields": ["chunk_text"],
            "query": "Who founded Apple?",
            "parameters": {"task_type": "question_answering"},
        }
    ],
    include_fields=["chunk_text"],
)
```

```bash curl theme={null}
curl -X POST "https://$INDEX_HOST/namespaces/example-namespace/documents/search" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "top_k": 3,
    "score_by": [
      {
        "type": "embed",
        "fields": ["chunk_text"],
        "query": "Who founded Apple?",
        "parameters": { "task_type": "question_answering" }
      }
    ],
    "include_fields": ["chunk_text"]
  }'
```

### Use a symmetric task

This creates an index that embeds support tickets with `clustering`. Its queries use `clustering` too, so a search returns the tickets most similar to the one you pass in, which you can use to find duplicates or group related issues.

```python Python theme={null}
schema = (
    SchemaBuilder()
      .add_string_field(
          name="ticket_text",
          embed={
              "model": "gemini-embedding-2",
              "write_parameters": {"task_type": "clustering"},
          },
      )
      .build()
)
pc.indexes.create(name="support-tickets", schema=schema)
```

```javascript JavaScript theme={null}
await pc.indexes.create({
  name: 'support-tickets',
  schema: {
    fields: {
      ticket_text: {
        type: 'string',
        embed: {
          model: 'gemini-embedding-2',
          writeParameters: { task_type: 'clustering' },
        },
      },
    },
  },
  waitUntilReady: true,
});
```

```go Go theme={null}
ticketModel := "gemini-embedding-2"
writeParameters := map[string]interface{}{"task_type": "clustering"}
_, err = pc.CreateIndex(ctx, &pinecone.CreateIndexRequest{
    Name: "support-tickets",
    Schema: pinecone.IndexSchema{
        Fields: map[string]pinecone.IndexSchemaField{
            "ticket_text": {
                String: &pinecone.StringField{
                    Embed: &pinecone.EmbedConfig{
                        Model:           &ticketModel,
                        WriteParameters: &writeParameters,
                    },
                },
            },
        },
    },
})
if err != nil {
    log.Fatalf("Failed to create index: %v", err)
}
```

```bash curl theme={null}
curl -X POST "https://api.pinecone.io/indexes" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "name": "support-tickets",
    "schema": {
      "fields": {
        "ticket_text": {
          "type": "string",
          "embed": {
            "model": "gemini-embedding-2",
            "write_parameters": { "task_type": "clustering" }
          }
        }
      }
    }
  }'
```

After you upsert tickets, search with a new ticket's text to find similar ones:

```python Python theme={null}
index = pc.index(name="support-tickets")

response = index.documents.search(
    namespace="example-namespace",
    top_k=5,
    score_by=[
        {"type": "embed", "fields": ["ticket_text"], "query": "Login fails after a password reset."}
    ],
    include_fields=["ticket_text"],
)
```

```javascript JavaScript theme={null}
const tickets = pc.index({ name: 'support-tickets', namespace: 'example-namespace' });

const similar = await tickets.documents.search({
  topK: 5,
  scoreBy: [
    { type: 'embed', fields: ['ticket_text'], query: 'Login fails after a password reset.' },
  ],
  includeFields: ['ticket_text'],
});
```

```go Go theme={null}
ticketsIdx, err := pc.DescribeIndex(ctx, "support-tickets")
if err != nil {
    log.Fatalf("Failed to describe index: %v", err)
}

ticketsConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: ticketsIdx.Host, Namespace: "example-namespace"})
if err != nil {
    log.Fatalf("Failed to create IndexConnection: %v", err)
}

ticketQuery := "Login fails after a password reset."
similar, err := ticketsConnection.SearchDocuments(ctx, &pinecone.SearchDocumentsRequest{
    TopK: 5,
    ScoreBy: []pinecone.DocumentScoringMethod{
        {Type: pinecone.DocumentScoringTypeEmbed, Fields: []string{"ticket_text"}, Query: &ticketQuery},
    },
    IncludeFields: []string{"ticket_text"},
})
if err != nil {
    log.Fatalf("Failed to search documents: %v", err)
}
fmt.Println(similar)
```

```bash curl theme={null}
curl -X POST "https://$INDEX_HOST/namespaces/example-namespace/documents/search" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{
    "top_k": 5,
    "score_by": [
      { "type": "embed", "fields": ["ticket_text"], "query": "Login fails after a password reset." }
    ],
    "include_fields": ["ticket_text"]
  }'
```

## Good to know

* **Dimension**: 3,072 by default, or any integer from 128 to 3,072. The metric is `cosine` only.
* **Input**: Text only. Pinecone doesn't support image, audio, or video input for this model yet.
* **Processing location**: `global` only. See [Processing locations](https://docs.pinecone.io/guides/index-data/processing-locations.md).
* **Availability**: Integrated embedding on document indexes only, on the Builder, Standard, and Enterprise plans.
