Simple OpenAI API Test"; // Your API key $apiKey = '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'; echo "
Testing OpenAI API...
"; $data = [ 'model' => 'gpt-4', 'messages' => [ ['role' => 'user', 'content' => 'Say "Hello" only.'] ], 'max_tokens' => 10 ]; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => 'https://api.openai.com/v1/chat/completions', CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer ' . $apiKey ], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HEADER => true ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); curl_close($ch); $headers = substr($response, 0, $headerSize); $body = substr($response, $headerSize); echo "HTTP Status: $httpCode
"; if ($httpCode == 200) { echo "✅ SUCCESS! API is working
"; $data = json_decode($body, true); if (isset($data['choices'][0]['message']['content'])) { echo "Response: " . htmlspecialchars($data['choices'][0]['message']['content']) . "
"; } } elseif ($httpCode == 429) { echo "❌ RATE LIMITED!
"; $data = json_decode($body, true); if (isset($data['error']['message'])) { echo "Error: " . htmlspecialchars($data['error']['message']) . "
"; } echo "" . htmlspecialchars($line) . "
"; } } echo "❌ AUTHENTICATION FAILED!
"; echo "Your API key may be invalid or expired.
"; } else { echo "❌ ERROR! HTTP $httpCode
"; echo "Response: " . htmlspecialchars($body) . "
"; } echo "" . htmlspecialchars($headers) . ""; echo "
✅ Your API is working! You can now use the enhanced files:
"; echo "includes/config.php with the enhanced versionincludes/GptHelper.php with the enhanced versionsimple_foreground_processor.php with the enhanced version⚠️ You're rate limited. Follow these steps:
"; echo "❌ Fix the API issue first, then proceed with enhancements.
"; } ?>