Generate batch embeddings
/google/v1beta/models/{modelsId}:batchEmbedContents● SupportedRequest parameters
modelstringrequiredpath: 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
ListModelsmethod. Format:models/{model}requestsarrayrequiredRequired. 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.
Expand sub-fields (6)
contentobjectoptional◐ Partially supportedRequired. The content to embed. Only the
parts.textfields will be counted.Text parts only; images return 400, including on multimodal embedding models.
embedContentConfigobjectoptional◐ 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.
Expand sub-fields (6)
audioTrackExtractionbooleanoptional○ UnsupportedOptional. Whether to extract audio from video content.
Passing this returns 400; this embedding option is currently unsupported.
autoTruncatebooleanoptional○ 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.
documentOcrbooleanoptional○ UnsupportedOptional. Whether to enable OCR for document content.
Passing this returns 400; this embedding option is currently unsupported.
outputDimensionalityintegeroptional◐ 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.
taskTypestringoptional○ UnsupportedOptional. The task type of the embedding.
Passing this returns 400; this embedding option is currently unsupported.
titlestringoptional○ UnsupportedOptional. The title for the text.
Passing this returns 400; this embedding option is currently unsupported.
modelstringoptionalRequired. 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
ListModelsmethod. Format:models/{model}Must match the model in the URL path, otherwise returns 400.
outputDimensionalityintegeroptional◐ 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.
taskTypestringoptional○ 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.
titlestringoptional○ UnsupportedOptional. Deprecated: Please use EmbedContentConfig.title instead. An optional title for the text. Only applicable when TaskType is
RETRIEVAL_DOCUMENT. Note: Specifying atitleforRETRIEVAL_DOCUMENTprovides 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
Request
curl
curl https://api.deepraxis.com/google/v1beta/models/text-embedding-3-small:batchEmbedContents \
-H "x-goog-api-key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"requests":[{"content":{"parts":[{"text":"第一条"}]}},{"content":{"parts":[{"text":"第二条"}]}}]}'Python
from google import genai
from google.genai import types
client = genai.Client(
api_key="$PRAXIS_API_KEY",
http_options=types.HttpOptions(base_url="https://api.deepraxis.com/google"),
)
resp = client.models.embed_content(
model="text-embedding-3-small",
contents=["第一条", "第二条"],
)
for embedding in resp.embeddings:
print(embedding.values)TypeScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: "$PRAXIS_API_KEY",
httpOptions: { baseUrl: "https://api.deepraxis.com/google" },
});
const resp = await ai.models.embedContent({
model: "text-embedding-3-small",
contents: ["第一条", "第二条"],
});
for (const embedding of resp.embeddings ?? []) console.log(embedding.values);Response 200
{
"embeddings": [
{
"values": [
-0.026688681915402412,
-0.037877585738897324,
0.08132540434598923,
-0.004256384912878275,
"… (1024 项)"
]
},
{
"values": [
-0.0032429357524961233,
-0.041793204843997955,
0.05447297915816307,
0.021508345380425453,
"… (1024 项)"
]
}
],
"usageMetadata": {
"promptTokenCount": 5
}
}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. |