Encountering 'model not found' error while trying to use GPT-4 with the OpenAI API

I am attempting to interact with the OpenAI API, but I’m facing issues specifically related to GPT-4. While my code executes perfectly with the gpt-3.5-turbo model, I encounter problems when I attempt to implement the GPT-4 models.

$input_text = "Can you tell me about dogs?";

// Set up cURL for making a request to OpenAI
$curl_instance = curl_init();

curl_setopt($curl_instance, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($curl_instance, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_instance, CURLOPT_POST, true);

$request_headers = array();
$request_headers[] = 'Content-Type: application/json';
$request_headers[] = 'Authorization: Bearer [YOUR-API-KEY]';
curl_setopt($curl_instance, CURLOPT_HTTPHEADER, $request_headers);

$request_payload = json_encode(array(
    'model' => 'gpt-4',
    'messages' => array(
        array('role' => 'system', 'content' => 'You are a knowledgeable assistant'),
        array('role' => 'user', 'content' => $input_text)
    )
));

curl_setopt($curl_instance, CURLOPT_POSTFIELDS, $request_payload);

$response_data = curl_exec($curl_instance);
echo $response_data . "<br>";

if (curl_errno($curl_instance)) {
    echo 'cURL Error: ' . curl_error($curl_instance) . "<br>";
} else {
    echo "Successfully completed the request<br>";
    echo "Response content:<br>";
    print_r(json_decode($response_data, true));
}

curl_close($curl_instance);

$parsed_response = json_decode($response_data, true);
$generated_output = $parsed_response['choices'][0]['message']['content'];

echo "AI Output: " . $generated_output . "<br>";

When I try to use the gpt-4 model, the following error message appears:

Processing input: what will the weather be like in Newcastle?
{
  "error": {
    "message": "The model: `gpt-4` does not exist",
    "type": "invalid_request_error",
    "param": null,
    "code": "model_not_found"
  }
}

I have also tried using gpt-4-0613 and encountered the same issue. The models based on gpt-3.5-turbo seem to work without any issues. What could be the reason for this?

That error’s definitely a permissions issue, not your code. OpenAI switched to a tiered system - you need Tier 1 status for GPT-4, which means making at least one payment first. Here’s what tripped me up: even after paying, there’s sometimes a delay before the models unlock. Check your account limits page in the dashboard - it’ll show exactly which models you can use. Since your code works with GPT-3.5, you’re all set once the account upgrade kicks in.

Same thing happened to me. OpenAI changed their access model - you need to be a Tier 1 user now, which means spending at least $5 first. Once you hit that, GPT-4 models unlock. Check your usage tier in account settings. If you’re still Tier 0, that’s why you’re getting the model_not_found error.

Had the same exact problem when I started with GPT-4. It’s not your code - it’s OpenAI’s access restrictions. They gate GPT-4 behind usage requirements, so you need payment history before these models unlock. After your first payment, there’s usually a wait before GPT-4 shows up. Took about two weeks for me after I paid. Your PHP code’s fine since it works with gpt-3.5-turbo - this is just account provisioning. Check the playground too - if GPT-4 isn’t there, the API won’t work either.

This is an account tier problem. GPT-4 isn’t available on standard OpenAI accounts - you need to make at least one payment first. Even after that, you’ll hit usage limits based on your account history and payment tier. I had the same issue a few months ago and had to wait for my first billing cycle to finish before GPT-4 appeared. Check your model access in the models endpoint or account dashboard. The error message is pretty clear about availability, so it’s definitely permissions, not your code.

you might not have access to gpt-4 yet. openai usually requires special permission for that model. check your account settings or hit up support. gpt-3.5 works fine without that, but gpt-4 needs some extra steps.