Gemini Text Embedding (embedContent)
Text Embedding Series
Gemini Text Embedding (embedContent)
POST
Gemini Text Embedding (embedContent)
Introduction
Use the Gemini native API to convert text to vector embeddings. The model is specified in the URL path (e.g.gemini-embedding-001). Use this when you need Google embedding models or alignment with the Gemini API.
This complements the Embeddings (OpenAI-style) endpoint: this doc describes the Gemini native path; the same capability is also available via
POST /v1/embeddings.Authentication
Bearer token, e.g.
Bearer sk-xxxxxxxxxxPath Parameters
Embedding model name, e.g.
gemini-embedding-001. Do not send model in the request body.Request Parameters
Content to embed. Must include a
parts array; each item is { "text": "your text" }.Output vector dimension (supported only by some models, e.g.
gemini-embedding-001, text-embedding-004).Task type, e.g.
RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY (optional).cURL Example
Python Example
Batch (batchEmbedContents)
For batch embedding use:POST /v1/models/{model}:batchEmbedContents with a requests array; each item has the same shape as a single request (including content.parts). Do not include model in each item.
Supported Models
| Model | Description |
|---|---|
| gemini-embedding-001 | General-purpose embedding model; supports outputDimensionality |
| text-embedding-004 | High-accuracy embedding model |
Notes
- The model is specified in the URL path; do not include
modelin the request body content.partsis required with at least one non-emptytext- Usage is returned in
metadata.usage(prompt_tokens,total_tokens)
