Embedding Series
Gemini Text Embedding (embedContent)
Convert text to vector embeddings using Gemini native interface
POST
Introduction
Convert text to vector embeddings using Gemini native interface. The model is specified via URL path (e.g.,gemini-embedding-001), suitable for scenarios requiring Google embedding models or alignment with Gemini API.
Complements the OpenAI format in Text Embedding: this document covers the Gemini native path; the same capability is also available via POST /v1/embeddings.
Authentication
Bearer Token, e.g.,Bearer sk-xxxxxxxxxx
Path Parameters
Embedding model name, e.g.,
gemini-embedding-001.Request Parameters
Content to embed. Must contain a
parts array, each item as { "text": "text content" }.Output vector dimensions (only supported by some models, e.g.,
gemini-embedding-001, text-embedding-004).Task type, e.g.,
RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY (optional).Code Examples
- cURL
- cURL (with dimensions)
- Python
Response Example
Batch Interface (batchEmbedContents)
For batch embedding, use:POST /v1/models/{model}:batchEmbedContents. The request body is a requests array, each item with the same structure as single requests (including content.parts), and do not include the model field in each item.
Supported Models
| Model | Description |
|---|---|
| gemini-embedding-001 | General-purpose embedding model, supports outputDimensionality |
| text-embedding-004 | High-precision embedding model |
Notes
content.partsis required, at least onetextmust be non-empty- Model is specified via URL path, do not include
modelfield in request body - Usage information is in
metadata.usagein the response (prompt_tokens,total_tokens)