-1

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

Nick ODell
  • 15,465
  • 3
  • 32
  • 66

1 Answers1

3

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:

Screenshot 1

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

Screenshot 2

But the documentation above is misleading because it's not updated yet. It's misleading in terms of:

  • Requirement to get access: On July 6, 2023, the requirement was to make at least one successful payment, while now the requirement is to make a successful payment of $1 or more.
  • Which GPT-4 models are accessible: Only the GPT-4 8k models (i.e., gpt-4 and gpt-4-0613) are accessible, not the GPT-4 32k models (i.e., gpt-4-32k and gpt-4-32k-0613).

Read 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 new developers by the end of July 2023 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 everyone who wants to make a quick payment and get access immediately, read the following sentence again:

/.../ We plan to open up access to new developers by the end of July 2023. /.../

Meaning, if you make a payment today (i.e., July 12, 2023), you'll not get API access to the GPT-4 8k models immediately. You can expect to get access by the end of July 2023.

Why don't I get access to the GPT-4 API even though I paid $20 for my ChatGPT Plus subscription?

OpenAI API usage is not included in the ChatGPT Plus subscription, as stated in the official OpenAI article:

  1. Is the ChatGPT API included in the ChatGPT Plus subscription?

    a. No, the ChatGPT API and ChatGPT Plus subscription are billed separately. The API has its own pricing, which can be found at https://openai.com/pricing. The ChatGPT Plus subscription covers usage on https://chat.openai.com/ only and costs $20/month.

You could already have paid hundreds of dollars for a ChatGPT Plus subscription and still not get access to the OpenAI API (i.e., including GPT-4 API).

I see two reasons for that:

  1. Let's say you have a project that consumes a lot of tokens. You could then buy ChatGPT Plus subscription and pay just $20/month while consuming tokens via the OpenAI API worth more than $20/month.
  2. OpenAI API usage works according to the pay-as-you-go principle. Meaning the OpenAI API can't be accessible with any kind of subscription.
Rok Benko
  • 14,265
  • 2
  • 24
  • 49
  • 1
    I made my first payment on July first, and I still cannot use GPT-4. – crlb Jul 18 '23 at 12:40
  • @crlb Try to create a new API key and use the new one. Let me know if this solves your problem. – Rok Benko Jul 18 '23 at 13:08
  • 1
    Tried that, did not work. – crlb Jul 18 '23 at 20:47
  • I just set up my paid account, and added my card. Now, bill would be deducted at the end of the month. How to make a payment of 1$ before that? – Raghav Arora Aug 08 '23 at 12:29
  • @RaghavArora I don't think you can "speed up" the billing process (read the [article](https://help.openai.com/en/articles/6640792-when-can-i-expect-to-receive-my-openai-api-invoice) on that matter). – Rok Benko Aug 09 '23 at 11:03
  • I made more then one payment, but gpt-4-32k is not available for me – Yuriy Zaletskyy Aug 16 '23 at 14:50
  • @YuriyZaletskyy Read my answer carefully again: *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.* Only the GPT-4 8k models (i.e., `gpt-4` and `gpt-4-0613`) are accessible via the API as of today. – Rok Benko Aug 16 '23 at 15:08
  • Is there a way to credit some money? I am up to $0.42 and would need to create a loop constantly calling the API just to get above $1. – MadMac Aug 21 '23 at 06:14
  • 1
    @MadMac If that's your goal, I suggest you use [DALL·E](https://platform.openai.com/docs/models/dall-e). Why? 1) It's the most expensive OpenAI model. 2) Using the loop will very possibly hit your rate limit sooner or later. 3) Why not play a bit with generative AI? It's fun (at least to me). – Rok Benko Aug 28 '23 at 15:21