EmbeddingsClient.EmbedAsync Method

Definition

Overloads

EmbedAsync(EmbeddingsOptions, CancellationToken)

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

EmbedAsync(RequestContent, String, RequestContext)

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

EmbedAsync(EmbeddingsOptions, CancellationToken)

Source:
EmbeddingsClient.cs

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

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Inference.EmbeddingsResult>> EmbedAsync (Azure.AI.Inference.EmbeddingsOptions embeddingsOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member EmbedAsync : Azure.AI.Inference.EmbeddingsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Inference.EmbeddingsResult>>
override this.EmbedAsync : Azure.AI.Inference.EmbeddingsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Inference.EmbeddingsResult>>
Public Overridable Function EmbedAsync (embeddingsOptions As EmbeddingsOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of EmbeddingsResult))

Parameters

embeddingsOptions
EmbeddingsOptions
cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

embeddingsOptions is null.

Examples

This sample shows how to call EmbedAsync.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EmbeddingsClient client = new EmbeddingsClient(endpoint, credential);

EmbeddingsOptions embeddingsOptions = null;
Response<EmbeddingsResult> response = await client.EmbedAsync(embeddingsOptions);

This sample shows how to call EmbedAsync.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EmbeddingsClient client = new EmbeddingsClient(endpoint, credential);

EmbeddingsOptions embeddingsOptions = null;
Response<EmbeddingsResult> response = await client.EmbedAsync(embeddingsOptions);

Applies to

EmbedAsync(RequestContent, String, RequestContext)

Source:
EmbeddingsClient.cs

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

public virtual System.Threading.Tasks.Task<Azure.Response> EmbedAsync (Azure.Core.RequestContent content, string extraParams = default, Azure.RequestContext context = default);
abstract member EmbedAsync : Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.EmbedAsync : Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function EmbedAsync (content As RequestContent, Optional extraParams As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

content
RequestContent

The content to send as the body of the request.

extraParams
String

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. Allowed values: "error" | "drop" | "pass-through"

context
RequestContext

The request context, 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