OpenAI API:为什么我无法通过API访问GPT-4模型,尽管GPT-3.5模型可以工作?

18
我可以使用gpt-3.5-turbo-0301模型访问ChatGPT API,但无法访问任何gpt-4模型。以下是我用于测试的代码(其中不包括我的OpenAI API密钥)。代码按原样运行,但当我将"gpt-3.5-turbo-0301"替换为"gpt-4"、"gpt-4-0314"或"gpt-4-32k-0314"时,会出现错误"openai.error.InvalidRequestError: The model: gpt-4 does not exist"。我有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)

1
可以通过OpenAI自己的接口成功使用GPT-4。你是指https://platform.openai.com/playground吗? - Franck Dernoncourt
1
@FranckDernoncourt,目前游乐场不允许您使用gpt-4模型。 - courtsimas
1
@courtsimas 谢谢,你说得对。 (我遇到了与OP相同的问题,所以我试图弄清楚GPT-4是否应该出现在playground中。在我的情况下,问题是我没有意识到访问GPT-4是与组织ID相关联的。) - Franck Dernoncourt
1
@FranckDernoncourt 我创建了一个(非官方的)API Python库,使用selenium导航到chat.openai.com,并为您提供gpt4的访问权限(如果您拥有chatgpt plus账户)。请注意,这违反了他们的服务条款,可能会导致您被禁止使用。https://github.com/Erol444/gpt4-openai-api - Erol444
4个回答

16

目前,GPT 4 API 受到限制,即使是具有 Chat GPT + 订阅的用户也是如此。

您可能需要加入 等待列表 来获取 API。


3
希望错误信息能明确说明这就是问题所在!谢谢。 - AllAmericanBreakfast
不仅如此,您可以通过贡献评估来更快地加入,但由于没有人批准PR,这是非常缓慢的。 - Loop

11

TL;DR: 现在没有等候名单了。自2023年7月6日起,GPT-4 8k模型通过API对那些通过OpenAI开发者平台成功付款1美元或更多的用户开放。如果您的旧API密钥是在付款之前生成的,请生成一个新的API密钥。

正如官方OpenAI文章所述:

如果您成功支付了1美元或更多,您将能够访问GPT-4 8k API。


即使我过去没有花费至少1美元,我是否可以通过API立即访问GPT-4 8k模型?

2023年8月18日之后创建的账户,在购买价值0.50美元或更多的预付费积分后,可以通过API立即访问GPT-4 8k模型。您可以在这里阅读有关预付费计费的信息。


为什么我支付了20美元的ChatGPT Plus订阅费,却无法通过API访问GPT-4 8k模型?

根据官方的OpenAI文章,ChatGPT Plus订阅并不包含OpenAI API的使用权:

  1. ChatGPT API是否包含在ChatGPT Plus订阅中?

    a. 不包含。ChatGPT API和ChatGPT Plus订阅是分开计费的。API有自己的定价,详情请参考https://openai.com/pricing。ChatGPT Plus订阅仅适用于https://chat.openai.com/,每月费用为20美元。


5
我要补充Crypto的回答,即gpt-4-32k-0314目前还无法访问。目前只有8k GPT-4模型可用:

enter image description here

一个人可以按照以下方式列出所有可用的模型(首先运行pip install openai):
# Author: Viet Dac Lai
import openai
import pprint

openai.organization = "org-insertorgIDhere"
openai.api_key = "sk-insertyourkeyhere"

GPT4 = 'gpt-4-0314'
MODEL_NAME = GPT4
model = openai.Model(MODEL_NAME)

def list_all_models():
    model_list = openai.Model.list()['data']
    model_ids = [x['id'] for x in model_list]
    model_ids.sort()
    pprint.pprint(model_ids)

if __name__ == '__main__':
    list_all_models()

如果没有GPT-4访问,则在2023年3月18日输出:

['ada',
 'ada-code-search-code',
 'ada-code-search-text',
 'ada-search-document',
 'ada-search-query',
 'ada-similarity',
 'ada:2020-05-03',
 'babbage',
 'babbage-code-search-code',
 'babbage-code-search-text',
 'babbage-search-document',
 'babbage-search-query',
 'babbage-similarity',
 'babbage:2020-05-03',
 'code-cushman-001',
 'code-davinci-002',
 'code-davinci-edit-001',
 'code-search-ada-code-001',
 'code-search-ada-text-001',
 'code-search-babbage-code-001',
 'code-search-babbage-text-001',
 'curie',
 'curie-instruct-beta',
 'curie-search-document',
 'curie-search-query',
 'curie-similarity',
 'curie:2020-05-03',
 'cushman:2020-05-03',
 'davinci',
 'davinci-if:3.0.0',
 'davinci-instruct-beta',
 'davinci-instruct-beta:2.0.0',
 'davinci-search-document',
 'davinci-search-query',
 'davinci-similarity',
 'davinci:2020-05-03',
 'gpt-3.5-turbo',
 'gpt-3.5-turbo-0301',
 'if-curie-v2',
 'if-davinci-v2',
 'if-davinci:3.0.0',
 'text-ada-001',
 'text-ada:001',
 'text-babbage-001',
 'text-babbage:001',
 'text-curie-001',
 'text-curie:001',
 'text-davinci-001',
 'text-davinci-002',
 'text-davinci-003',
 'text-davinci-edit-001',
 'text-davinci-insert-001',
 'text-davinci-insert-002',
 'text-davinci:001',
 'text-embedding-ada-002',
 'text-search-ada-doc-001',
 'text-search-ada-query-001',
 'text-search-babbage-doc-001',
 'text-search-babbage-query-001',
 'text-search-curie-doc-001',
 'text-search-curie-query-001',
 'text-search-davinci-doc-001',
 'text-search-davinci-query-001',
 'text-similarity-ada-001',
 'text-similarity-babbage-001',
 'text-similarity-curie-001',
 'text-similarity-davinci-001',
 'whisper-1']

如果有权访问 GPT-4,则以下两个模型将被添加到列表中:
'gpt-4',
'gpt-4-0314',

请注意,访问GPT-4需要OpenAI账户和组织ID(在https://openai.com/waitlist/gpt-4-api上,其中一个字段是组织ID)的绑定。

我看到 Twitter 发布了一条消息,他们获得了 32K GPT-4 API 访问权限,每个 API 请求的费用大约为 2 美元,这不是很便宜吗? - Haseeb Mir
@HaseebMir 我使用Azure上的GPT-4 32k:https://i.stack.imgur.com/SAOyb.png。不确定openai.com,我现在只用Azure。 - Franck Dernoncourt
那太好了,但我看到有人在OpenAI Playground中使用了32k Context API,并将整个代码库作为参考。 - Haseeb Mir
@HaseebMir 很好,我想它终于发布了!除非你提到的人是内部人员,比如OpenAI雇员 :) 但由于Azure通常落后于openai.com,因此很可能已通过等待列表公开发布。 - Franck Dernoncourt
是的,32K API和其他GPT-4 API仍然有很长的等待列表。 - Haseeb Mir

0

如何获得GPT-4的访问权限?目前,即使您拥有Chat GPT+订阅,也需要获得邀请才能使用。如何获得邀请?您需要加入他们的等待列表。

如何加入等待列表?点击这里。他们曾经在横幅中放置了链接,但我现在没有看到它(他们可能为某些用户提供该链接)。

您需要获取组织ID(即使您是私人),它在这里。他们还会要求您用一小段话解释为什么需要它:“您是否有特定的想法要使用GPT-4构建?我们特别关注以前无法使用我们其他模型的用例。”


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接