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

# Gemini 同步批量向量

> 同步批量向量结构与当前模型别名限制。

当前版本 `30a6d88a4` 的 `controller/relay.go` 用大小写敏感的 `strings.Contains(path, "embed")` 分发原生向量。`:batchEmbedContents` 自身没有小写 `embed`，因此批量调用要求路径模型 ID 含小写 `embed`（例如实际可用的 embedding 模型名）；不含该片段的别名可能进入错误分支。示例在发送前拒绝这类批量别名。此限制来自当前实现，不是 Gemini 协议要求；升级网关后应复核。

`POST /v1beta/models/{model}:batchEmbedContents`

发送 `requests` 数组，每项包含 `model` 和 `content.parts`，同一请求使用相同模型。返回 `embeddings[].values`，按输入顺序关联。

路径 `model` 使用裸 ID。网关会按路径模型映射并改写请求模型。`taskType`、`title`、`outputDimensionality` 支持依模型而定，不接受空输入作为有效示例。不是 SSE 或异步 Batch；更多边界和可运行示例见[原生向量指南](/zh/guides/gemini-embeddings)。

[Read in English](/en/api-reference/gemini-batch-embed)


## OpenAPI

````yaml openapi/relay.json POST /v1beta/models/{model}:batchEmbedContents
openapi: 3.0.3
info:
  title: API — Core inference API
  version: 0.5.0
  description: >-
    面向接入的精选规范，不是全部管理或供应商接口。 / Curated integration specification, not the entire
    management or provider API.
  license:
    name: AGPL-3.0-or-later
servers:
  - url: https://gateway.example.com
    description: >-
      Example only; replace with your gateway origin and optional path prefix,
      without /v1.
security:
  - BearerAuth: []
paths:
  /v1beta/models/{model}:batchEmbedContents:
    post:
      summary: Gemini 同步批量向量 / Gemini synchronous batch embeddings
      description: >-
        发送 `requests` 数组，每项包含 `model` 和 `content.parts`，同一请求使用相同模型。返回
        `embeddings[].values`，按输入顺序关联。 / Send `requests`, each with `model` and
        `content.parts`, using one model per batch. Associate
        `embeddings[].values` with inputs in order. 当前版本要求路径模型名含小写 embed，详见指南 /
        This revision requires lowercase embed in the path model name; see the
        guide.
      operationId: gemini_batch_embed
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                requests:
                  type: array
                  items:
                    type: object
                    properties:
                      model:
                        type: string
                        description: models/ 前缀的模型名 / Model name prefixed with models/
                      content:
                        type: object
                        properties:
                          parts:
                            type: array
                            items:
                              type: object
                              properties:
                                text:
                                  type: string
                              additionalProperties: true
                              required:
                                - text
                        additionalProperties: true
                        required:
                          - parts
                      taskType:
                        type: string
                      title:
                        type: string
                      outputDimensionality:
                        type: integer
                        minimum: 1
                    additionalProperties: true
                    required:
                      - content
              additionalProperties: true
              required:
                - requests
      responses:
        '200':
          description: >-
            读取业务字段，不只检查 HTTP 状态 / Validate business fields, not only HTTP
            status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  embeddings:
                    type: array
                    items:
                      type: object
                      properties:
                        values:
                          type: array
                          items:
                            type: number
                      additionalProperties: true
                      required:
                        - values
                additionalProperties: true
                required:
                  - embeddings
              example:
                embeddings:
                  - values:
                      - 0.1
                      - 0.2
        default:
          description: 错误格式与状态取决于入口 / Error status and shape depend on the entry.
      security:
        - GeminiApiKey: []
        - BearerAuth: []
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 模型调用 API Key，不是控制台登录凭据 / Model API key, not console login credentials
    GeminiApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: 网关令牌 / Gateway token

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.