OpenAI GPT-4 API错误: “模型 gpt-4 不存在”

huangapple go评论124阅读模式
英文:

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 = &quot;Prompt....&quot;

// GPT-4 API call
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, &#39;https://api.openai.com/v1/chat/completions&#39;);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = &#39;Content-Type: application/json&#39;;
$headers[] = &#39;Authorization: Bearer [API-KEY]&#39;;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$data = json_encode(array(&#39;model&#39; =&gt; &#39;gpt-3.5-turbo&#39;, 
                          &#39;messages&#39; =&gt; array(
                                            array(&#39;role&#39; =&gt; &#39;system&#39;, &#39;content&#39; =&gt; &#39;Your system message here&#39;), 
                                            array(&#39;role&#39; =&gt; &#39;user&#39;, &#39;content&#39; =&gt; $your_prompt))));

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($ch);
echo $result.&quot;&lt;br&gt;&quot;;

if (curl_errno($ch)) {
    echo &#39;Curl Error:&#39; . curl_error($ch) . &quot;\n&lt;br&gt;&quot;;
} else {
    echo &quot;API call successful.\n&lt;br&gt;&quot;;
    echo &quot;API response: \n&lt;br&gt;&quot;;
    print_r(json_decode($result, true));
    echo &quot;\n&quot;;
}
curl_close($ch);

$response = json_decode($result, true);
$text = $response[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;];

echo &quot;OutputGPT&quot; . $text . &quot;\n&lt;br&gt;&quot;;

When I'm using gpt-4 I get:

Processing prompt: what is a wether today in Warsaw Poland
{ &quot;error&quot;: { &quot;message&quot;: &quot;The model: `gpt-4` does not exist&quot;, &quot;type&quot;: &quot;invalid_request_error&quot;, &quot;param&quot;: null, &quot;code&quot;: &quot;model_not_found&quot; } }
API call successful.
API response:
Array ( [error] =&gt; Array ( [message] =&gt; The model: `gpt-4` does not exist [type] =&gt; invalid_request_error [param] =&gt; [code] =&gt; 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模型,您可以看到以下通知:

OpenAI GPT-4 API错误: “模型 gpt-4 不存在”

而对于GPT-3.5模型,没有这样的通知:

OpenAI GPT-4 API错误: “模型 gpt-4 不存在”

正如官方的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:

OpenAI GPT-4 API错误: “模型 gpt-4 不存在”

While for the GPT-3.5 models, there's no such notice:

OpenAI GPT-4 API错误: “模型 gpt-4 不存在”

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.

huangapple
  • 本文由 发表于 2023年7月10日 19:08:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76653119.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定