题意:使用 OpenAI API 并尝试通过 os.getenv()
方法来获取 API 密钥,但发现它不起作用
问题背景:
I am just trying some simple functions in Python with OpenAI APIs but running into an error:
在Python中使用OpenAI的API进行一些简单的功能,但遇到了错误
I have a valid API secret key which I am using.
有一个有效的 API 密钥正在使用
Code: 代码:
>>> import os
>>> import openai
>>> openai.api_key = os.getenv("I have placed the key here")
>>> response = openai.Completion.create(model="text-davinci-003", prompt="Say this is a test", temperature=0, max_tokens=7)