Reputation: 1187
I just created my first API key, and I want use the gpt-3.5-turbo model just for simple test, here is my code :
$url = "https://api.openai.com/v1/chat/completions";
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
// copy past from the tutorial https://platform.openai.com/docs/api-reference/making-requests , I don't know what "temperature" is for..
$data = [
'model' => 'gpt-3.5-turbo',
'messages' => [
['role' => 'user', 'content' => 'Say this is a test!']
],
"temperature" => "0.7"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$decodedResponse = json_decode($response, true);
var_dump($decodedResponse);
I keep getting "You exceeded your current quota, please check your plan and billing details." but accordingly to openAI, when using gpt-3.5-turbo model I should have 3 RPM. (request per minute) or 200 RPD (request per minute) for free and I'm far to reach the limit.
Any idea?
Thanks
Upvotes: 0
Views: 1814
Reputation: 1
Use Project API keys instead of User API keys from OpenAI settings.
Upvotes: 0