Gets a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
Check the generic variables needed to use the API and the supported models.
Method |
Path |
Description |
POST |
/embeddings |
Creates an embedding vector representing the input |
Creates an embedding vector representing the input provided.
Parameter |
Type |
Description |
input |
string or array |
Input to embed, encoded as a string(4). To embed multiple inputs in a single request, pass an array of strings. The input must not exceed the max input tokens for the model and cannot be an empty string |
model |
string |
provider/modelId to use |
encoding_format(1) |
string |
The format to return the embeddings. It can be either float (default) or base64 (optional) |
dimensions(1) |
integer |
The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3* and later models (optional) |
user(3) |
string |
A unique identifier representing your end-user |
input_type(2) |
string |
Defines how the input data will be used when generating embeddings (optional) |
timeout |
integer |
The maximum time, in seconds, to wait for the API to respond. Defaults to 600 seconds |
Check the valid providers in the Providers column of the Supported Chat Models.
(1): Only supported by openAI provider. The maximum input token is 8191 (roughly ten standard pages of text).
(2): Check if the selected embeddings model supports this option.
(3): openAI specific.
(4): If the embedding model support image embeddings; pass in a base64 encoded image string to the input parameter with the associated mime type (check the samples section).
You can use the X-Saia-Cache-Enabled (true or false default) to cache the embeddings for the model; it applies by Organization/Project.
{
"model": "openai/text-embedding-3-small",
"input" : "Help me with Globant Enterprise AI!"
}
{
"model": "openai/text-embedding-3-small",
"input" : ["Help me with", "Globant Enterprise AI!"]
}
The expected response is similar to the following:
{
"model": "text-embedding-3-small",
"data": [
{
"embedding": [...],
"index": 0,
"object": "embedding"
},...
],
"object": "list",
"usage": {
"completion_tokens": number,
"prompt_tokens": number,
"total_tokens": number,
"completion_tokens_details": null
}
}
curl --location '$BASE_URL/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
--data '{
"model": "openai/text-embedding-3-small",
"input" : "Help me with Globant Enterprise AI!"
}'
curl --location '$BASE_URL/embeddings' \
--header 'X-Saia-Cache-Enabled: true' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
--data '{
"model": "openai/text-embedding-3-small",
"input" : "Help me with", "Globant Enterprise AI!"
}'
curl --location '$BASE_URL/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
--data '{
"model": "vertex_ai/text-embedding-004",
"input_type": "SEMANTIC_SIMILARITY", // RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT and other options
"input" : "Help me with", "Globant Enterprise AI!"
}'
curl --location '$BASE_URL/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
--data '{
"model": "nvidia/nv-embedqa-e5-v5",
"input" : "identify", "yourself!",
"input_type": "passage" // passage or query
}'
API Reference
openAI Embeddings
VertexAI Text Embeddings