InferenceClient.GetEmbeddingsAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| GetEmbeddingsAsync(RequestContent, RequestContext) |
[Protocol Method] Embeds text, queries and document images and returns dense or multi-vector embeddings as numbers or base64. Text
and queries are sent inline. Images are read from the caller's Azure Blob Storage with a caller-signed user
delegation SAS (Microsoft Entra callers only). Results come back in the response or, with
|
| GetEmbeddingsAsync(IEnumerable<EmbeddingInput>, String, Nullable<EmbeddingVectorKind>, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, Nullable<EmbeddingOutputDataKind>, Nullable<EmbeddingEncodingFormat>, Nullable<EmbeddingDelivery>, CancellationToken) |
Embeds text, queries and document images and returns dense or multi-vector embeddings as numbers or base64. Text
and queries are sent inline. Images are read from the caller's Azure Blob Storage with a caller-signed user
delegation SAS (Microsoft Entra callers only). Results come back in the response or, with |
| GetEmbeddingsAsync(IEnumerable<Object>, String, Nullable<EmbeddingVectorKind>, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, Nullable<EmbeddingOutputDataKind>, Nullable<EmbeddingEncodingFormat>, Nullable<EmbeddingDelivery>, CancellationToken) |
Embeds text, queries and document images using loosely typed items, for example anonymous objects or dictionaries.
Each item is serialized to JSON with JsonSerializer using camelCase property and dictionary key naming and must produce
a JSON object with only the wire properties |
GetEmbeddingsAsync(RequestContent, RequestContext)
- Source:
- InferenceClient.cs
[Protocol Method] Embeds text, queries and document images and returns dense or multi-vector embeddings as numbers or base64. Text
and queries are sent inline. Images are read from the caller's Azure Blob Storage with a caller-signed user
delegation SAS (Microsoft Entra callers only). Results come back in the response or, with delivery: link, as a
time-limited read-only link.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<Azure.Response> GetEmbeddingsAsync(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member GetEmbeddingsAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetEmbeddingsAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetEmbeddingsAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request options, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content is null.
Service returned a non-success status code.
Applies to
GetEmbeddingsAsync(IEnumerable<EmbeddingInput>, String, Nullable<EmbeddingVectorKind>, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, Nullable<EmbeddingOutputDataKind>, Nullable<EmbeddingEncodingFormat>, Nullable<EmbeddingDelivery>, CancellationToken)
- Source:
- InferenceClient.cs
Embeds text, queries and document images and returns dense or multi-vector embeddings as numbers or base64. Text
and queries are sent inline. Images are read from the caller's Azure Blob Storage with a caller-signed user
delegation SAS (Microsoft Entra callers only). Results come back in the response or, with delivery: link, as a
time-limited read-only link.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>> GetEmbeddingsAsync(System.Collections.Generic.IEnumerable<Azure.Data.AI.EmbeddingInput> inputs, string model, Azure.Data.AI.EmbeddingVectorKind? vectorKind = default, int? dimensions = default, int? multiVectorDimensions = default, int? maxVectorCount = default, Azure.Data.AI.EmbeddingOutputDataKind? outputDataKind = default, Azure.Data.AI.EmbeddingEncodingFormat? encodingFormat = default, Azure.Data.AI.EmbeddingDelivery? delivery = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetEmbeddingsAsync : seq<Azure.Data.AI.EmbeddingInput> * string * Nullable<Azure.Data.AI.EmbeddingVectorKind> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<Azure.Data.AI.EmbeddingOutputDataKind> * Nullable<Azure.Data.AI.EmbeddingEncodingFormat> * Nullable<Azure.Data.AI.EmbeddingDelivery> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>>
override this.GetEmbeddingsAsync : seq<Azure.Data.AI.EmbeddingInput> * string * Nullable<Azure.Data.AI.EmbeddingVectorKind> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<Azure.Data.AI.EmbeddingOutputDataKind> * Nullable<Azure.Data.AI.EmbeddingEncodingFormat> * Nullable<Azure.Data.AI.EmbeddingDelivery> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>>
Public Overridable Function GetEmbeddingsAsync (inputs As IEnumerable(Of EmbeddingInput), model As String, Optional vectorKind As Nullable(Of EmbeddingVectorKind) = Nothing, Optional dimensions As Nullable(Of Integer) = Nothing, Optional multiVectorDimensions As Nullable(Of Integer) = Nothing, Optional maxVectorCount As Nullable(Of Integer) = Nothing, Optional outputDataKind As Nullable(Of EmbeddingOutputDataKind) = Nothing, Optional encodingFormat As Nullable(Of EmbeddingEncodingFormat) = Nothing, Optional delivery As Nullable(Of EmbeddingDelivery) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of EmbeddingResult))
Parameters
- inputs
- IEnumerable<EmbeddingInput>
The items to embed, in order: 1 to 32 items. Currently a request can have at most one text or query item and
at most 8 images. Images can be up to 20 MiB and 50 megapixels each (JPEG, PNG, GIF or WebP), with at most 20 MiB
of images per request. The request body can be up to 30,000,000 bytes.
- model
- String
The model to use, for example microsoft-embedding-1-large (Microsoft Embedding 1-large).
- vectorKind
- Nullable<EmbeddingVectorKind>
The kind of vectors to return. Defaults to dense.
The number of dimensions per vector; with dense_multi, of the dense vector. Must be a value the model supports for the
requested vector kind; the model's native width is the default.
For dense_multi only: the number of dimensions per multi-vector. Must be a value the model supports for multi-vectors;
the model's native multi-vector width is the default.
For multi and dense_multi only: the most multi-vectors to return per item.
- outputDataKind
- Nullable<EmbeddingOutputDataKind>
The numeric type of the returned values, for every vector in the response. Defaults to float32 for dense and
float16 for multi and dense_multi.
- encodingFormat
- Nullable<EmbeddingEncodingFormat>
How vectors are encoded in the response. Defaults to float.
- delivery
- Nullable<EmbeddingDelivery>
How to return the results. An explicit value wins. Without it, a request with images gets link where the
endpoint has a result store, and every other request gets inline.
- cancellationToken
- CancellationToken
The cancellation token that can be used to cancel the operation.
Returns
Exceptions
inputs or model is null.
model is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Applies to
GetEmbeddingsAsync(IEnumerable<Object>, String, Nullable<EmbeddingVectorKind>, Nullable<Int32>, Nullable<Int32>, Nullable<Int32>, Nullable<EmbeddingOutputDataKind>, Nullable<EmbeddingEncodingFormat>, Nullable<EmbeddingDelivery>, CancellationToken)
- Source:
- InferenceClient.cs
Embeds text, queries and document images using loosely typed items, for example anonymous objects or dictionaries.
Each item is serialized to JSON with JsonSerializer using camelCase property and dictionary key naming and must produce
a JSON object with only the wire properties kind (optional, defaults to text), id, content, url and sasToken
(all optional, string values). C#-cased names such as Content map to the wire names and EmbeddingContentKind values
are written as their string value. JsonElement items must use the exact wire names. Unknown or duplicate properties are rejected.
EmbeddingInput instances are used as-is.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>> GetEmbeddingsAsync(System.Collections.Generic.IEnumerable<object> inputs, string model, Azure.Data.AI.EmbeddingVectorKind? vectorKind = default, int? dimensions = default, int? multiVectorDimensions = default, int? maxVectorCount = default, Azure.Data.AI.EmbeddingOutputDataKind? outputDataKind = default, Azure.Data.AI.EmbeddingEncodingFormat? encodingFormat = default, Azure.Data.AI.EmbeddingDelivery? delivery = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetEmbeddingsAsync : seq<obj> * string * Nullable<Azure.Data.AI.EmbeddingVectorKind> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<Azure.Data.AI.EmbeddingOutputDataKind> * Nullable<Azure.Data.AI.EmbeddingEncodingFormat> * Nullable<Azure.Data.AI.EmbeddingDelivery> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>>
override this.GetEmbeddingsAsync : seq<obj> * string * Nullable<Azure.Data.AI.EmbeddingVectorKind> * Nullable<int> * Nullable<int> * Nullable<int> * Nullable<Azure.Data.AI.EmbeddingOutputDataKind> * Nullable<Azure.Data.AI.EmbeddingEncodingFormat> * Nullable<Azure.Data.AI.EmbeddingDelivery> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Data.AI.EmbeddingResult>>
Public Overridable Function GetEmbeddingsAsync (inputs As IEnumerable(Of Object), model As String, Optional vectorKind As Nullable(Of EmbeddingVectorKind) = Nothing, Optional dimensions As Nullable(Of Integer) = Nothing, Optional multiVectorDimensions As Nullable(Of Integer) = Nothing, Optional maxVectorCount As Nullable(Of Integer) = Nothing, Optional outputDataKind As Nullable(Of EmbeddingOutputDataKind) = Nothing, Optional encodingFormat As Nullable(Of EmbeddingEncodingFormat) = Nothing, Optional delivery As Nullable(Of EmbeddingDelivery) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of EmbeddingResult))
Parameters
- inputs
- IEnumerable<Object>
The items to embed.
- model
- String
The model to use.
- vectorKind
- Nullable<EmbeddingVectorKind>
The kind of vectors to return.
- outputDataKind
- Nullable<EmbeddingOutputDataKind>
The data kind of the returned vectors.
- encodingFormat
- Nullable<EmbeddingEncodingFormat>
The encoding format of the returned vectors.
- delivery
- Nullable<EmbeddingDelivery>
How results are delivered.
- cancellationToken
- CancellationToken
The cancellation token that can be used to cancel the operation.
Returns
Exceptions
model, inputs or one of its items is null.
model is empty. An item is not a JSON object, has an unknown or duplicate property, or supplies a value of the wrong type (for example a kind that is not a non-empty string). A missing kind is allowed.
Service returned a non-success status code.