Skip to content

Commit

Permalink
fix(playground): if base url is provided but not api key, use fake ap…
Browse files Browse the repository at this point in the history
…i key for openai client (#6259)
  • Loading branch information
RogerHYang authored Feb 4, 2025
1 parent 70f4107 commit afb818a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/phoenix/server/api/helpers/playground_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,10 @@ def __init__(
from openai import AsyncOpenAI

base_url = model.base_url or os.environ.get("OPENAI_BASE_URL")
if not (api_key := api_key or os.environ.get("OPENAI_API_KEY")) and not base_url:
raise BadRequest("An API key is required for OpenAI models")
if not (api_key := api_key or os.environ.get("OPENAI_API_KEY")):
if not base_url:
raise BadRequest("An API key is required for OpenAI models")
api_key = "sk-fake-api-key"
client = AsyncOpenAI(api_key=api_key, base_url=base_url)
super().__init__(client=client, model=model, api_key=api_key)
self._attributes[LLM_PROVIDER] = OpenInferenceLLMProviderValues.OPENAI.value
Expand Down

0 comments on commit afb818a

Please sign in to comment.