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
  • string

    Type: string

    The string that will be turned into an embedding.

    Default: ``

    Example: This is a test.

  • array

    Type: string[]

    The array of strings that will be turned into an embedding.

    Min items: 1

    Max items: 1

    Example
    [
      "['This is a test.']"
    ]
    

Input text to embed, provided as a string or a one-element array. The input must not exceed the model's maximum input token limit (8,192 tokens for all embedding models). It cannot be an empty string, and the array cannot be nested.

Example: The quick brown fox jumped over the lazy dog

model

Any of 1 type
  • Type: string

    Example: example

ID of the model to use. You can use the List models API to see all of your available models.

Example: emb://<folder_id>/text-embeddings-v2-doc/

dimensions

Type: integer

The number of dimensions the resulting output embeddings should have.

Min value: 1

encoding_format

Type: string

The format to return the embeddings in. Can be float only.

Default: float

Const: float

user

Type: string

A unique identifier representing your end-user, which can help Yandex to monitor and detect abuse.

Example: 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
[
  {
    "index": 0,
    "embedding": [
      0.5
    ],
    "object": "embedding"
  }
]

model

Type: string

The name of the model used to generate the embedding.

Example: example

object

Type: string

The object type, which is always "list".

Const: list

Example: example

usage

Type: object

prompt_tokens

Type: integer

The number of tokens used by the prompt.

total_tokens

Type: integer

The total number of tokens used by the request.

The usage information for the request.

Example
{
  "prompt_tokens": 0,
  "total_tokens": 0
}

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
[
  0.5
]

index

Type: integer

The index of the embedding in the list of embeddings.

object

Type: string

The object type, which is always "embedding".

Const: embedding

Example: example

Example
{
  "index": 0,
  "embedding": [
    0.5
  ],
  "object": "embedding"
}
Предыдущая
Следующая