Del via


Get Embeddings - Get Embeddings

Return the embedding vectors for given text prompts. The method makes a REST API call to the /embeddings route on the given endpoint.

POST https:///embeddings?api-version=2024-05-01-preview

URI Parameters

Name In Required Type Description
api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Header

Name Required Type Description
extra-parameters

ExtraParameters

Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. This sets the HTTP request header extra-parameters.

Request Body

Name Required Type Description
input True

string[]

Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays.

dimensions

integer (int32)

Optional. The number of dimensions the resulting output embeddings should have. Passing null causes the model to use its default value. Returns a 422 error if the model doesn't support the value or parameter.

encoding_format

EmbeddingEncodingFormat

Optional. The desired format for the returned embeddings.

input_type

EmbeddingInputType

Optional. The type of the input. Returns a 422 error if the model doesn't support the value or parameter.

model

string

ID of the specific AI model to use, if more than one model is available on the endpoint.

Responses

Name Type Description
200 OK

EmbeddingsResult

The request has succeeded.

Other Status Codes

Azure.Core.Foundations.ErrorResponse

An unexpected error response.

Headers

x-ms-error-code: string

Security

api-key

Type: apiKey
In: header

OAuth2Auth

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

Scopes

Name Description
https://ml.azure.com/.default

Examples

maximum set embeddings
minimum set embeddings

maximum set embeddings

Sample request

POST https:///embeddings?api-version=2024-05-01-preview


{
  "input": [
    "This is a very good text"
  ],
  "dimensions": 1024,
  "encoding_format": "float",
  "input_type": "text",
  "model": "my-model-name"
}

Sample response

{
  "id": "cknxthfa",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    }
  ],
  "object": "list",
  "model": "my-model-name",
  "usage": {
    "prompt_tokens": 15,
    "total_tokens": 15
  }
}

minimum set embeddings

Sample request

POST https:///embeddings?api-version=2024-05-01-preview

{
  "input": [
    "This is a very good text"
  ]
}

Sample response

{
  "id": "cknxthfa",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    }
  ],
  "object": "list",
  "model": "my-model-name",
  "usage": {
    "prompt_tokens": 15,
    "total_tokens": 15
  }
}

Definitions

Name Description
Azure.Core.Foundations.Error

The error object.

Azure.Core.Foundations.ErrorResponse

A response containing error details.

Azure.Core.Foundations.InnerError

An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.

EmbeddingEncodingFormat

Specifies the types of embeddings to generate. Compressed embeddings types like uint8, int8, ubinary and binary, may reduce storage costs without sacrificing the integrity of the data. Returns a 422 error if the model doesn't support the value or parameter. Read the model's documentation to know the values supported by the your model.

EmbeddingInputType

Represents the input types used for embedding search.

EmbeddingItem

Representation of a single embeddings relatedness comparison.

EmbeddingsOptions

The configuration information for an embeddings request.

EmbeddingsResult

Representation of the response data from an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.

EmbeddingsUsage

Measurement of the amount of tokens used in this request and response.

ExtraParameters

Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload.

Azure.Core.Foundations.Error

The error object.

Name Type Description
code

string

One of a server-defined set of error codes.

details

Azure.Core.Foundations.Error[]

An array of details about specific errors that led to this reported error.

innererror

Azure.Core.Foundations.InnerError

An object containing more specific information than the current object about the error.

message

string

A human-readable representation of the error.

target

string

The target of the error.

Azure.Core.Foundations.ErrorResponse

A response containing error details.

Name Type Description
error

Azure.Core.Foundations.Error

The error object.

Azure.Core.Foundations.InnerError

An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.

Name Type Description
code

string

One of a server-defined set of error codes.

innererror

Azure.Core.Foundations.InnerError

Inner error.

EmbeddingEncodingFormat

Specifies the types of embeddings to generate. Compressed embeddings types like uint8, int8, ubinary and binary, may reduce storage costs without sacrificing the integrity of the data. Returns a 422 error if the model doesn't support the value or parameter. Read the model's documentation to know the values supported by the your model.

Value Description
base64

Get back binary representation of the embeddings encoded as Base64 string. OpenAI Python library retrieves embeddings from the API as encoded binary data, rather than using intermediate decimal representations as is usually done.

binary

Get back signed binary embeddings

float

Get back full precision embeddings

int8

Get back signed int8 embeddings

ubinary

Get back unsigned binary embeddings

uint8

Get back unsigned int8 embeddings

EmbeddingInputType

Represents the input types used for embedding search.

Value Description
document

Indicates the input represents a document that is stored in a vector database.

query

Indicates the input represents a search query to find the most relevant documents in your vector database.

text

Indicates the input is a general text input.

EmbeddingItem

Representation of a single embeddings relatedness comparison.

Name Type Description
embedding

number[] (float)

List of embedding values for the input prompt. These represent a measurement of the vector-based relatedness of the provided input. Or a base64 encoded string of the embedding vector.

index

integer (int32)

Index of the prompt to which the EmbeddingItem corresponds.

object enum:

embedding

The object type of this embeddings item. Will always be embedding.

EmbeddingsOptions

The configuration information for an embeddings request.

Name Type Description
dimensions

integer (int32)

Optional. The number of dimensions the resulting output embeddings should have. Passing null causes the model to use its default value. Returns a 422 error if the model doesn't support the value or parameter.

encoding_format

EmbeddingEncodingFormat

Optional. The desired format for the returned embeddings.

input

string[]

Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays.

input_type

EmbeddingInputType

Optional. The type of the input. Returns a 422 error if the model doesn't support the value or parameter.

model

string

ID of the specific AI model to use, if more than one model is available on the endpoint.

EmbeddingsResult

Representation of the response data from an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.

Name Type Description
data

EmbeddingItem[]

Embedding values for the prompts submitted in the request.

id

string

Unique identifier for the embeddings result.

model

string

The model ID used to generate this result.

object enum:

list

The object type of the embeddings result. Will always be list.

usage

EmbeddingsUsage

Usage counts for tokens input using the embeddings API.

EmbeddingsUsage

Measurement of the amount of tokens used in this request and response.

Name Type Description
prompt_tokens

integer (int32)

Number of tokens in the request.

total_tokens

integer (int32)

Total number of tokens transacted in this request/response. Should equal the number of tokens in the request.

ExtraParameters

Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload.

Value Description
drop

The service will ignore (drop) extra parameters in the request payload. It will only pass the known parameters to the back-end AI model.

error

The service will error if it detected extra parameters in the request payload. This is the service default.

pass-through

The service will pass extra parameters to the back-end AI model.