我可以使用 gpt-3.5-turbo-0301 模型访问 ChatGPT API,但不能使用任何 gpt-4 模型。这是我用来测试这个的代码(它不包括我的 openai API 密钥)。代码按编写的方式运行,但是当我用“gpt-4”、“gpt-4-0314”或“gpt-4-32k-0314”替换“gpt-3.5-turbo-0301”时,它给了我一个错误“openai.error.InvalidRequestError:模型:gpt-4不存在”。我有 ChatGPT+ 订阅,正在使用自己的 API 密钥,并且可以通过 OpenAI 自己的界面成功使用 gpt-4。
如果我使用 gpt-4-0314 或 gpt-4-32k-0314,也会出现同样的错误。我看过几篇文章,声称此或类似的代码可以使用“gpt-4”作为模型规范,我在下面粘贴的代码来自其中一篇。有谁知道是否可以通过Python + API访问gpt-4模型,如果可以,你该怎么做?
openai_key = "sk..."
openai.api_key = openai_key
system_intel = "You are GPT-4, answer my questions as if you were an expert in the field."
prompt = "Write a blog on how to use GPT-4 with python in a jupyter notebook"
# Function that calls the GPT-4 API
def ask_GPT4(system_intel, prompt):
result = openai.ChatCompletion.create(model="gpt-3.5-turbo-0301",
messages=[{"role": "system", "content": …Run Code Online (Sandbox Code Playgroud)