Share via


AzureTextToImage Class

Azure Text to Image service.

Initialize an AzureTextToImage service.

Constructor

AzureTextToImage(service_id: str | None = None, api_key: str | None = None, deployment_name: str | None = None, endpoint: str | None = None, base_url: str | None = None, api_version: str | None = None, ad_token: str | None = None, ad_token_provider: Callable[[], str | Awaitable[str]] | None = None, token_endpoint: str | None = None, default_headers: Mapping[str, str] | None = None, async_client: AsyncAzureOpenAI | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None)

Parameters

Name Description
service_id

The service ID. (Optional)

Default value: None
api_key

The optional api key. If provided, will override the value in the env vars or .env file.

Default value: None
deployment_name

The optional deployment. If provided, will override the value (text_to_image_deployment_name) in the env vars or .env file.

Default value: None
endpoint

The optional deployment endpoint. If provided will override the value in the env vars or .env file.

Default value: None
base_url

The optional deployment base_url. If provided will override the value in the env vars or .env file.

Default value: None
api_version

The optional deployment api version. If provided will override the value in the env vars or .env file.

Default value: None
ad_token

The Azure AD token for authentication. (Optional)

Default value: None
ad_token_provider

Azure AD Token provider. (Optional)

Default value: None
token_endpoint

The Azure AD token endpoint. (Optional)

Default value: None
default_headers

The default headers mapping of string keys to string values for HTTP requests. (Optional)

Default value: None
async_client

An existing client to use. (Optional)

Default value: None
env_file_path

Use the environment settings file as a fallback to environment variables. (Optional)

Default value: None
env_file_encoding

The encoding of the environment settings file. (Optional)

Default value: None

Methods

from_dict

Initialize an Azure OpenAI service from a dictionary of settings.

from_dict

Initialize an Azure OpenAI service from a dictionary of settings.

from_dict(settings: dict[str, Any]) -> T_

Parameters

Name Description
settings
Required

A dictionary of settings for the service. should contain keys: deployment_name, endpoint, api_key and optionally: api_version, ad_auth

Attributes

ai_model_type

ai_model_type: OpenAIModelTypes

client

client: AsyncOpenAI

completion_tokens

completion_tokens: int

prompt_tokens

prompt_tokens: int

total_tokens

total_tokens: int