Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions py/autoevals/oai.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ def prepare_openai_complete(is_async=False, api_key=None):

openai_obj = openai
is_v1 = False
base_url = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaults to https://api.openai.com/v1 if none specified

if hasattr(openai, "OpenAI"):
# This is the new v1 API
is_v1 = True
if is_async:
openai_obj = openai.AsyncOpenAI(api_key=api_key)
openai_obj = openai.AsyncOpenAI(api_key=api_key, base_url=base_url)
else:
openai_obj = openai.OpenAI(api_key=api_key)
openai_obj = openai.OpenAI(api_key=api_key, base_url=base_url)

try:
from braintrust.oai import wrap_openai
Expand Down