Files
portfoliowai/api/test_models.php
T

24 lines
611 B
PHP

<?php
require_once __DIR__ . '/../config/db.php';
$apiKey = getenv('GEMINI_API_KEY') ?: ($_ENV['GEMINI_API_KEY'] ?? '');
if (empty($apiKey)) {
echo "API Key is missing in .env";
exit;
}
$url = "https://generativelanguage.googleapis.com/v1/models?key=" . urlencode($apiKey);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: $httpCode\n\n";
echo "Response:\n";
echo $response;