Skip to main content
POST
Embeddings

Request

Body parameters

string
required
Embedding model ID. Options: text-embedding-3-small, togethercomputer/m2-bert-80M-32k-retrieval, gemini-embedding-001, gemini-embedding-2-preview.
string | array
required
Text to embed. Can be a single string or an array of strings.
integer
Number of dimensions for the output vector. Supported by models trained with Matryoshka Representation Learning (MRL): text-embedding-3-small (up to 1536), gemini-embedding-001 and gemini-embedding-2-preview (128–3072, recommended: 768, 1536, 3072). If omitted, the model’s default is used.
string
Format of the embedding. Options: "float" (default), "base64".
string
A unique identifier for the end-user, used for abuse monitoring.

Examples

Gemini Embedding 2 with custom dimensions

gemini-embedding-2-preview is a premium model. It requires wallet balance. It is Google’s first multimodal embedding model with 8K token input and 3072-dimensional vectors with Matryoshka support.

Batch embeddings


Model comparison

For gemini-embedding-001 and gemini-embedding-2-preview, the default 3072-dimensional output is already normalized. For smaller dimensions (768, 1536), normalize the output vectors yourself (L2 norm) for best cosine similarity results.

Response