EmbeddingsClient Class
EmbeddingsClient.
- Inheritance
-
azure.ai.inference._client.EmbeddingsClientEmbeddingsClient
Constructor
EmbeddingsClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, *, dimensions: int | None = None, encoding_format: str | EmbeddingEncodingFormat | None = None, input_type: str | EmbeddingInputType | None = None, model: str | None = None, model_extras: Dict[str, Any] | None = None, **kwargs: Any)
Parameters
Name | Description |
---|---|
endpoint
Required
|
Service host. Required. |
credential
Required
|
Credential used to authenticate requests to the service. Is either a AzureKeyCredential type or a TokenCredential type. Required. |
Keyword-Only Parameters
Name | Description |
---|---|
dimensions
|
Optional. The number of dimensions the resulting output embeddings should have. Default value is None. |
encoding_format
|
Optional. The desired format for the returned embeddings. Known values are: "base64", "binary", "float", "int8", "ubinary", and "uint8". Default value is None. |
input_type
|
Optional. The type of the input. Known values are: "text", "query", and "document". Default value is None. |
model
|
ID of the specific AI model to use, if more than one model is available on the endpoint. Default value is None. |
model_extras
|
Additional, model-specific parameters that are not in the
standard request payload. They will be added as-is to the root of the JSON in the request body.
How the service handles these extra parameters depends on the value of the
|
api_version
|
The API version to use for this operation. Default value is "2024-05-01-preview". Note that overriding this default value may result in unsupported behavior. |
Methods
close | |
embed |
Return the embedding vectors for given text prompts. The method makes a REST API call to the /embeddings route on the given endpoint. |
get_model_info |
Returns information about the AI model.
The method makes a REST API call to the |
send_request |
Runs the network request through the client's chained policies.
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
close
close() -> None
embed
Return the embedding vectors for given text prompts. The method makes a REST API call to the /embeddings route on the given endpoint.
embed(*, input: List[str], dimensions: int | None = None, encoding_format: str | _models.EmbeddingEncodingFormat | None = None, input_type: str | _models.EmbeddingInputType | None = None, model: str | None = None, model_extras: Dict[str, Any] | None = None, **kwargs: Any) -> _models.EmbeddingsResult
Parameters
Name | Description |
---|---|
body
Required
|
Is either a MutableMapping[str, Any] type (like a dictionary) or a IO[bytes] type that specifies the full request payload. Required. |
Keyword-Only Parameters
Name | Description |
---|---|
input
|
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. Required. |
dimensions
|
Optional. The number of dimensions the resulting output embeddings should have. Default value is None. |
encoding_format
|
Optional. The desired format for the returned embeddings. Known values are: "base64", "binary", "float", "int8", "ubinary", and "uint8". Default value is None. |
input_type
|
Optional. The type of the input. Known values are: "text", "query", and "document". Default value is None. |
model
|
ID of the specific AI model to use, if more than one model is available on the endpoint. Default value is None. |
model_extras
|
Additional, model-specific parameters that are not in the
standard request payload. They will be added as-is to the root of the JSON in the request body.
How the service handles these extra parameters depends on the value of the
|
Returns
Type | Description |
---|---|
EmbeddingsResult. The EmbeddingsResult is compatible with MutableMapping |
Exceptions
Type | Description |
---|---|
get_model_info
Returns information about the AI model.
The method makes a REST API call to the /info
route on the given endpoint.
This method will only work when using Serverless API or Managed Compute endpoint.
It will not work for GitHub Models endpoint or Azure OpenAI endpoint.
get_model_info(**kwargs: Any) -> ModelInfo
Returns
Type | Description |
---|---|
ModelInfo. The ModelInfo is compatible with MutableMapping |
Exceptions
Type | Description |
---|---|
send_request
Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse
Parameters
Name | Description |
---|---|
request
Required
|
The network request you want to make. Required. |
Keyword-Only Parameters
Name | Description |
---|---|
stream
|
Whether the response payload will be streamed. Defaults to False. |
Returns
Type | Description |
---|---|
The response of your network call. Does not do error handling on your response. |
Azure SDK for Python