我可以使用 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": system_intel},
{"role": "user", "content": prompt}])
print(result['choices'][0]['message']['content'])
# Call the function above
ask_GPT4(system_intel, prompt)
目前,GPT 4 API 受到限制,甚至对拥有聊天 GPT 的用户也是如此+订阅。
您可能需要加入Waitlist https://openai.com/waitlist/gpt-4-api对于 API。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)