ImageEmbeddingsClient Class
ImageEmbeddingsClient.
Constructor
ImageEmbeddingsClient(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 endpoint URL for AI model inference. 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. Default value: 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. Default value: None
|
input_type
|
Optional. The type of the input. Known values are: "text", "query", and "document". Default value is None. Default value: None
|
model
|
ID of the specific AI model to use, if more than one model is available on the endpoint. Default value is None. Default value: 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
Default value: None
|
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 images. The method makes a REST API call to the /images/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 images. The method makes a REST API call to the /images/embeddings route on the given endpoint.
embed(*, input: List[_models.ImageEmbeddingInput], 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
|
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 image to embed. To embed multiple inputs in a single request, pass an array. The input must not exceed the max input tokens for the model. Required. Default value: <object object at 0x000002303C216270>
|
dimensions
|
Optional. The number of dimensions the resulting output embeddings should have. Default value is None. Default value: 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. Default value: None
|
input_type
|
Optional. The type of the input. Known values are: "text", "query", and "document". Default value is None. Default value: None
|
model
|
ID of the specific AI model to use, if more than one model is available on the endpoint. Default value is None. Default value: 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
Default value: None
|
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. Default value: False
|
Returns
Type | Description |
---|---|
The response of your network call. Does not do error handling on your response. |