英文:
OpenAI GPT-4 API error: "The model: gpt-4 does not exist"
问题
以下是翻译的代码部分:
我有以下代码,它在`gpt-3.5-turbo`模型上运行得很完美,但在`gpt-4`模型上却不起作用:
$your_prompt = "提示....";
// GPT-4 API 调用
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer [API-KEY]';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode(array('model' => 'gpt-3.5-turbo',
'messages' => array(
array('role' => 'system', 'content' => '这里是您的系统消息'),
array('role' => 'user', 'content' => $your_prompt))));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
echo $result."<br>";
if (curl_errno($ch)) {
echo 'Curl错误:' . curl_error($ch) . "<br>";
} else {
echo "API调用成功。<br>";
echo "API响应:<br>";
print_r(json_decode($result, true));
echo "<br>";
}
curl_close($ch);
$response = json_decode($result, true);
$text = $response['choices'][0]['message']['content'];
echo "输出GPT" . $text . "<br>";
当我使用gpt-4
时,我得到以下结果:
处理提示:今天在波兰华沙的天气如何
{ "error": { "message": "该模型:`gpt-4` 不存在", "type": "invalid_request_error", "param": null, "code": "model_not_found" } }
API调用成功。
API响应:
Array ( [error] => Array ( [message] => 该模型:`gpt-4` 不存在 [type] => invalid_request_error [param] => [code] => model_not_found ) ) 输出GPT
我也尝试了其他模型,比如gpt-3.5-turbo-0613
,它也可以工作,但对于gpt-4
以及gpt-4-0613
都不起作用。然而,根据https://platform.openai.com/docs/models/gpt-4,它应该是可用的。
英文:
I have code as below, it works perfect with model gpt-3.5-turbo
but not with gpt-4
:
$your_prompt = "Prompt...."
// GPT-4 API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer [API-KEY]';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode(array('model' => 'gpt-3.5-turbo',
'messages' => array(
array('role' => 'system', 'content' => 'Your system message here'),
array('role' => 'user', 'content' => $your_prompt))));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
echo $result."<br>";
if (curl_errno($ch)) {
echo 'Curl Error:' . curl_error($ch) . "\n<br>";
} else {
echo "API call successful.\n<br>";
echo "API response: \n<br>";
print_r(json_decode($result, true));
echo "\n";
}
curl_close($ch);
$response = json_decode($result, true);
$text = $response['choices'][0]['message']['content'];
echo "OutputGPT" . $text . "\n<br>";
When I'm using gpt-4
I get:
Processing prompt: what is a wether today in Warsaw Poland
{ "error": { "message": "The model: `gpt-4` does not exist", "type": "invalid_request_error", "param": null, "code": "model_not_found" } }
API call successful.
API response:
Array ( [error] => Array ( [message] => The model: `gpt-4` does not exist [type] => invalid_request_error [param] => [code] => model_not_found ) ) OutputGPT
I have tried also with others models like gpt-3.5-turbo-0613
and it works to, but not for gpt-4
as well as for gpt-4-0613
. Nevertheless it should based on https://platform.openai.com/docs/models/gpt-4
答案1
得分: 3
自2023年7月6日起,通过OpenAI开发者平台成功支付1美元或更多的用户可以通过API访问GPT-4 8k模型。
请查看官方OpenAI文档。
对于GPT-4模型,您可以看到以下通知:
而对于GPT-3.5模型,没有这样的通知:
正如官方的OpenAI文章所述:
> 在2023年7月6日,我们向所有API用户提供了GPT-4 8k API的访问权限,
> 只要他们成功支付了1美元或更多。我们计划很快向所有开发者开放
> 访问权限,然后根据计算资源的可用性逐渐提高速率限制。
>
> 我们目前不提供GPT-4 32k API的访问权限,但将在以后的日期提供。
>
> 对于2023年8月18日之后创建的API账户,购买了价值0.50美元或更多的预付费
> 信用后,您可以立即获得GPT-4的访问权限。您可以在这里了解有关预付费计费的信息。
附加说明:
-
即使我过去没有花费至少1美元,我是否可以通过API立即访问GPT-4 8k模型? 是的,如果您的帐户是在2023年8月18日之后创建的,并且您购买了价值0.50美元或更多的预付费信用。
-
为什么我无法通过API访问GPT-4 32k模型? 只有GPT-4 8k模型可以通过API访问。GPT-4 32k模型的API访问将在以后提供。
-
为什么我尽管为ChatGPT Plus订阅支付了20美元,却无法通过API访问GPT-4 8k模型? OpenAI API的使用不包括在ChatGPT Plus订阅中。
英文:
Since July 6, 2023, the GPT-4 8k models have been accessible through the API to those users who have made a successful payment of $1 or more through the OpenAI developer platform.
Take a look at the official OpenAI documentation.
For the GPT-4 models, you can see the following notice:
While for the GPT-3.5 models, there's no such notice:
As stated in the official OpenAI article:
> On July 6, 2023, we gave access to the GPT-4 8k API to all API users
> who have made a successful payment of $1 or more. We plan to open up
> access to all developers soon, and then start raising rate-limits
> after that depending on compute availability.
>
> We are not currently granting access to the GPT-4 32k API at this time, but it will be made available at a later date.
>
> For API accounts created after August 18, 2023, you can get instant
> access to GPT-4 after purchasing $0.50 worth or more of pre-paid
> credits. You can read about prepaid billing here.
Additional notes:
- Can I get instant access to GPT-4 8k models via API even if I haven't spent at least $1 in the past? Yes, if your account was created after August 18, 2023, and you purchase $0.50 worth or more of pre-paid credits.
- Why can't I access GPT-4 32k models via API? Only the GPT-4 8k models are available via API. Access to the GPT-4 32k models via API will be made available at a later date.
- Why don't I get access to the GPT-4 8k models via API even though I paid $20 for my ChatGPT Plus subscription? OpenAI API usage is not included in the ChatGPT Plus subscription.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论