From 01f227aa370784d451c42da94f01af173e52e777 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Fri, 5 May 2023 12:05:36 -0700 Subject: [PATCH] allow api_version to be set by environment variable --- openai/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openai/__init__.py b/openai/__init__.py index ecf663a3b0..3ff85c2662 100644 --- a/openai/__init__.py +++ b/openai/__init__.py @@ -48,8 +48,9 @@ organization = os.environ.get("OPENAI_ORGANIZATION") api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1") api_type = os.environ.get("OPENAI_API_TYPE", "open_ai") -api_version = ( - "2023-03-15-preview" if api_type in ("azure", "azure_ad", "azuread") else None +api_version = os.environ.get( + "OPENAI_API_VERSION", + ("2023-03-15-preview" if api_type in ("azure", "azure_ad", "azuread") else None), ) verify_ssl_certs = True # No effect. Certificates are always verified. proxy = None