I have a problem with my code on API so i created some simple code that use chatGPT API to answer my question so i try to make it and when i say hi it respond with: Sorry, I couldn’t understand that. Could you please try again? and on the console (inspect element) it says: POST https://api.openai.com/v1/completions 429
(anonymous) @ main.js:10
its always 429 i try to wait like 1 hour, 2 hour but its still error like that, is anybody can help me
i am in free plan btw.
<?php
require 'vendor/autoload.php';
function generateChatResponse($message) {
$openaiApiKey = 'MYKEY';
$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 i am getting ERROR
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.",
Thanks @Foxabilo for your immediate responses. Highly appreciate that.
But from community posts seems like adding card is not resolve the issue. Some people also getting this error after adding card.