From 32e4e64ea35b558d76b858b91f14f7b9d05dc189 Mon Sep 17 00:00:00 2001 From: Roger Yang <80478925+RogerHYang@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:34:35 -0800 Subject: [PATCH] fix(playground): add AZURE_OPENAI_API_KEY environment variable (#5570) --- src/phoenix/server/api/helpers/playground_clients.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/phoenix/server/api/helpers/playground_clients.py b/src/phoenix/server/api/helpers/playground_clients.py index 0b79147e4a..e7e84f6a6e 100644 --- a/src/phoenix/server/api/helpers/playground_clients.py +++ b/src/phoenix/server/api/helpers/playground_clients.py @@ -575,6 +575,8 @@ def __init__( super().__init__(model=model, api_key=api_key) self._attributes[LLM_PROVIDER] = OpenInferenceLLMProviderValues.AZURE.value self._attributes[LLM_SYSTEM] = OpenInferenceLLMSystemValues.OPENAI.value + if not (api_key := api_key or os.environ.get("AZURE_OPENAI_API_KEY")): + raise BadRequest("An Azure API key is required for Azure OpenAI models") if not (endpoint := model.endpoint or os.environ.get("AZURE_OPENAI_ENDPOINT")): raise BadRequest("An Azure endpoint is required for Azure OpenAI models") if not (api_version := model.api_version or os.environ.get("OPENAI_API_VERSION")):