Generate batch embeddings
Generate vector embeddings for several texts in one request.
/google/v1beta/models/{modelsId}:batchEmbedContents● SupportedRequest parameters
modelstring必填path: Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`
requestsarray必填Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`.
Accepts 1–100 items, returns them in input order, and requires matching dimensions.
▸ 展开子字段(6)
contentobject可选◐ Partially supportedRequired. The content to embed. Only the `parts.text` fields will be counted.
Text parts only; images return 400, including on multimodal embedding models.
embedContentConfigobject可选◐ Partially supportedOptional. Configuration for the EmbedContent request.
Only outputDimensionality is available, subject to model limits. Other options such as autoTruncate, documentOcr and audioTrackExtraction return 400.
▸ 展开子字段(6)
audioTrackExtractionboolean可选○ UnsupportedOptional. Whether to extract audio from video content.
Passing this returns 400; this embedding option is currently unsupported.
autoTruncateboolean可选○ UnsupportedOptional. Whether to silently truncate the input content if it's longer than the maximum sequence length.
Passing this returns 400; this embedding option is currently unsupported.
documentOcrboolean可选○ UnsupportedOptional. Whether to enable OCR for document content.
Passing this returns 400; this embedding option is currently unsupported.
outputDimensionalityinteger可选◐ Partially supportedOptional. Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end.
Tested dimensions work on text-embedding-3-small and qwen3-vl-embedding; doubao-embedding-vision requires at least 1024. bge-m3 and qwen3-embedding-0.6b error.
taskTypestring可选○ UnsupportedOptional. The task type of the embedding.
Passing this returns 400; this embedding option is currently unsupported.
titlestring可选○ UnsupportedOptional. The title for the text.
Passing this returns 400; this embedding option is currently unsupported.
modelstring可选Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`
Must match the model in the URL path, otherwise returns 400.
outputDimensionalityinteger可选◐ Partially supportedOptional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024 only. You cannot set this value if using the earlier model (`models/embedding-001`).
Tested dimensions work on text-embedding-3-small and qwen3-vl-embedding; doubao-embedding-vision requires at least 1024. bge-m3 and qwen3-embedding-0.6b error.
taskTypestring可选○ UnsupportedOptional. Deprecated: Please use EmbedContentConfig.task_type instead. Optional task type for which the embeddings will be used. Not supported on earlier models (`models/embedding-001`).
Passing this returns 400.
titlestring可选○ UnsupportedOptional. Deprecated: Please use EmbedContentConfig.title instead. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.
Passing this returns 400.
Returns
200
Each entry in requests follows the same rules as embedContent (text parts only, same rejections); every entry in a batch must use the same outputDimensionality. The current official JS and Python SDKs actually call this batch endpoint for embedContent.
Errors follow the Gemini API format — see error codes
Response
HTTP 200
Successful response
application/json
| Name | Type | Description |
|---|---|---|
| embeddings | array<object> | Output only. The embeddings for each request, in the same order as provided in the batch request. |
| embeddings[].shape | array<integer> | This field stores the soft tokens tensor frame shape (e.g. [1, 1, 256, 2048]). |
| embeddings[].values | array<number> | The embedding values. This is for 3P users only and will not be populated for 1P calls. |
| usageMetadata | object | Output only. The usage metadata for the request. |
| usageMetadata.promptTokenCount | integer | Output only. Number of tokens in the prompt. |
| usageMetadata.promptTokenDetails | array<object> | Output only. List of modalities that were processed in the request input. |