diff --git a/redisvl/utils/vectorize/text/azureopenai.py b/redisvl/utils/vectorize/text/azureopenai.py index a387e238..81a03803 100644 --- a/redisvl/utils/vectorize/text/azureopenai.py +++ b/redisvl/utils/vectorize/text/azureopenai.py @@ -61,7 +61,7 @@ def __init__( 'Deployment name' not the 'Model name'. Defaults to 'text-embedding-ada-002'. api_config (Optional[Dict], optional): Dictionary containing the - API key, API version, Azure endpoint, and any other API options. + API key, API version, Azure endpoint, Azure deployment, and any other API options. Defaults to None. Raises: @@ -127,6 +127,19 @@ def _initialize_clients(self, api_config: Optional[Dict]): "Provide it in api_config or set the AZURE_OPENAI_API_KEY\ environment variable." ) + + azure_deployment = ( + api_config.pop("azure_deployment") + if api_config + else os.getenv("AZURE_OPENAI_DEPLOYMENT") + ) + + if not azure_deployment: + raise ValueError( + "AzureOpenAI API deployment is required. " + "Provide it in api_config or set the AZURE_OPENAI_DEPLOYMENT\ + environment variable." + ) self._client = AzureOpenAI( api_key=api_key,