Just create an API key and try to use with PHP but getting error "429 Too Many Requests"

Hello, for learning purpose i generate the code to use Chat GPT with php. Code hint are generated from ChatGPT

require 'vendor/autoload.php';
function generateChatResponse($message) {
    $openaiApiKey = 'KEY;
    $url = 'https://api.openai.com/v1/chat/completions';

    $client = new GuzzleHttp\Client();

    $headers = [
        'Authorization' => 'Bearer ' . $openaiApiKey,
        'Content-Type' => 'application/json',

    $data = [
        'messages' => [['role' => 'system', 'content' => 'You are a PHP developer.']],
        'max_tokens' => 50, // Adjust the response length as per your requirements.
        'model' => 'gpt-3.5-turbo',

    $response = $client->post($url, [
        'headers' => $headers,
        'json' => $data,

    $responseBody = json_decode($response->getBody(), true);
    $reply = $responseBody['choices'][0]['message']['content'];

    return $reply;
$userMessage = 'Hello, how can I integrate ChatGPT with PHP?';
$chatReply = generateChatResponse($userMessage);
echo $chatReply; // Output the generated response

but soon when i render that file i am getting error

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://api.openai.com/v1/chat/completions resulted in a 429 Too Many Requests response: { “error”: { “message”: “You exceeded your current quota, please check your plan and billing details.”, (truncated…)"

also please guide me, how my credit used? I never create api before just created that. Is that trial balance auto deleted? is any way i can restore that credit again please.

With PHP the best and easy way to integrate please guide me

Welcome to the forum!

You need to add a payment card to your account here OpenAI Platform

So it mean there is “Free Lunch” in that. I have to add credit to use API there is not other way to use without credit.

then what this limit for?

Please guide me it shows 3 request per minute. and once next min started my quota updated? is that same or different

Sorry new to ChatGPT

You can see your 18$ grant expired on the 1st May, so now you need to have a payment method on there to continue to use the API.

ChatGPT and the Plus membership program is not the same thing as the API and both have different account management sections and are billed separately.

1 Like

Yeah u right it expired. but as i am free trial account user i guess i still have limit

Free trial users 3 RPM
150,000 TPM 3 RPM
40,000 TPM 3 RPM
150,000 TPM 5 images / min 3 RPM

dont that?

No, your trail has expired, you are now on normal usage.


Rather, you are now on the “no API access until we can charge your credit card for your usage” plan…

1 Like

Thanks @Foxabilo. I was different thoughts but thanks for correcting me. Now got the concept of that.