Generate dense vector embeddings for input text.
This endpoint creates numerical vector representations (embeddings) of text using specified embedding models. Embeddings are useful for semantic search, clustering, similarity comparisons, and RAG applications.
Request Body:
model: Embedding model ID (required) - Name of the model to use for generating embeddingsinput: Text or list of texts to embed (required) - Single string or array of strings. Cannot be empty and must not exceed max input tokens for the modeldimensions (optional): Number of dimensions for output embeddings (only applicable for Resizable Matryoshka Embedding models)Returns:
id: Unique identifier for the responseobject: Object type (always embedding)data: List of embedding objects, each containing:
object: Object type (always embedding)embedding: Vector of floats representing the text (length depends on the model)index: Position in the input arraymodel: Model ID used for generationcreated: Unix timestamp (seconds) when response was generatedusage: Token usage statistics containing:
total_tokens: Total number of tokens used by the requestExample Request (Single Text):
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}
{
"model": "text-embedding-xyz",
"input": "The quick brown fox jumps over the lazy dog"
}
Example Request (Multiple Texts):
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}
{
"model": "text-embedding-ada-002",
"input": [
"First document for semantic search",
"Second document for clustering",
"Third document for similarity comparison"
]
}
Example Request (With Dimensions):
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}
{
"model": "matryoshka-embed-model",
"input": "Sample text to embed",
"dimensions": 512
}
Example Response:
{
"id": "embed-abc123xyz",
"object": "embedding",
"data": [
{
"object": "embedding",
"embedding": [0.00658765, -0.008665467, -0.007653789, 0.0023, -0.0091, 0.0125],
"index": 0
}
],
"model": "text-embedding-ada-002",
"created": 1705329600.0,
"usage": {
"total_tokens": 10
}
}
Notes:
input fielddimensions parameter only with Matryoshka embedding models that support resizingBearer authentication header of the form Bearer <token>, where <token> is your auth token.
Input text to embed, encoded as a string or a list of strings. To embed multiple inputs in a single request, pass a list of strings. The input must not exceed the max input tokens for the model, cannot be an empty string.
"The quick brown fox jumped over the lazy dog"
The name of the model used to generate the embedding.
"nugen-flash-embed"
(Applicable for only Resizable Matryoshka Embedding models) The number of dimensions the resulting output embeddings should have.
Vector embeddings and usage statistics