Create an embedding
Creates an embedding vector representing the input text.
Request
POST
https://ai.api.cloud.yandex.net/v1/embeddings
Body
application/json
{
"input": "The quick brown fox jumped over the lazy dog",
"model": "emb://<folder_id>/text-embeddings-v2-doc/",
"encoding_format": "float",
"dimensions": 1,
"user": "example"
}
|
Name |
Description |
|
input |
One of: string or array
Input text to embed, encoded as a string or 1 element array. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models). Cannot be an empty string, and any array must be 1 dimension or less. Example: |
|
model |
Any of 1 type
ID of the model to use. You can use the List models API to see all of your available models. Example: |
|
dimensions |
Type: integer The number of dimensions the resulting output embeddings should have. Min value: |
|
encoding_format |
Type: string The format to return the embeddings in. Can be Default: Const: |
|
user |
Type: string A unique identifier representing your end-user, which can help Yandex to monitor and detect abuse. Example: |
Responses
200 OK
OK
Body
application/json
{
"data": [
{
"index": 0,
"embedding": [
0.5
],
"object": "embedding"
}
],
"model": "example",
"object": "list",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}
|
Name |
Description |
||||
|
data |
Type: Embedding[] The list of embeddings generated by the model. Example
|
||||
|
model |
Type: string The name of the model used to generate the embedding. Example: |
||||
|
object |
Type: string The object type, which is always "list". Const: Example: |
||||
|
usage |
Type: object
The usage information for the request. Example
|
Embedding
Represents an embedding vector returned by embedding endpoint.
|
Name |
Description |
|
embedding |
Type: number[] The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the embedding concepts. Example
|
|
index |
Type: integer The index of the embedding in the list of embeddings. |
|
object |
Type: string The object type, which is always "embedding". Const: Example: |
Example
{
"index": 0,
"embedding": [
0.5
],
"object": "embedding"
}