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

# Gemini Embedding 2 Preview

> Gemini Embedding 2 Preview：文本向量模型。包含 MixRoute 调用示例与参数。

Gemini Embedding 2 Preview 是 Google 推出的文本向量模型。

可通过 MixRoute 的 Gemini 原生端点调用 `gemini-embedding-2-preview`，同时支持 OpenAI 兼容端点。

## 核心能力

* Gemini embedContent - Gemini 原生向量端点
* 文本向量 - 将文本转换为数值向量
* 批量输入 - 支持字符串或字符串数组
* 相似度任务 - 可用于检索与聚类

## 快速示例

### Gemini embedContent

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.mixroute.ai/v1/models/gemini-embedding-2-preview:embedContent" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "content": {
        "parts": [
          {
            "text": "MixRoute model API"
          }
        ]
      }
    }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.post(
        "https://api.mixroute.ai/v1/models/gemini-embedding-2-preview:embedContent",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={'content': {'parts': [{'text': 'MixRoute model API'}]}},
    )

    print(response.json())
    ```
  </Tab>
</Tabs>

### OpenAI 兼容 Embeddings

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.mixroute.ai/v1/embeddings" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "model": "gemini-embedding-2-preview",
      "input": "MixRoute model API"
    }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.post(
        "https://api.mixroute.ai/v1/embeddings",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={'model': 'gemini-embedding-2-preview', 'input': 'MixRoute model API'},
    )

    print(response.json())
    ```
  </Tab>
</Tabs>

## 参数

### Gemini embedContent

| 参数                     | 类型      | 必填 | 说明               |
| ---------------------- | ------- | -- | ---------------- |
| `content`              | object  | 是  | 由 parts 组成的文本内容。 |
| `taskType`             | string  | 否  | 模型支持时指定向量任务类型。   |
| `outputDimensionality` | integer | 否  | 模型支持时指定输出维度。     |

### OpenAI 兼容 Embeddings

| 参数           | 类型              | 必填 | 说明                                |
| ------------ | --------------- | -- | --------------------------------- |
| `model`      | string          | 是  | 固定为 `gemini-embedding-2-preview`。 |
| `input`      | string \| array | 是  | 需要向量化的文本。                         |
| `dimensions` | integer         | 否  | 模型支持时指定输出维度。                      |
