-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixed in v1Issues addressed by the v1 betaIssues addressed by the v1 beta
Description
Describe the bug
I'm encountering an issue where I am unable to populate the api_key
, api_base
, api_type
, and api_version
using environment variables.
The openai package seems to read the api_key
, api_base
, api_type
, and api_version
from environment variables only at the moment it is imported. If these api configs are specified after the openai package is imported, they are not recognized.
The code is in here.
To Reproduce
Due to python's caching mechanism, to reproduce this issue, the openai package must be reloaded.
Code snippets
import openai
import os
os.environ["OPENAI_API_KEY"] = "<api_key>"
os.environ["OPENAI_API_BASE"] = "<api_base>"
os.environ["OPENAI_API_TYPE"] = "<api_type>"
os.environ["OPENAI_API_VERSION"] = "<api_version>"
openai.Completion.create(prompt="Hello", engine="text-davinci-003", max_tokens=5)
OS
Windows 11
Python version
Python v3.8.16
Library version
openai-python v0.27.8
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixed in v1Issues addressed by the v1 betaIssues addressed by the v1 beta