Files
saqel/backend/scripts/test_notebooklm_prompt.php
T

24 lines
873 B
PHP

<?php
$envFile = __DIR__ . '/../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) continue;
list($name, $value) = explode('=', $line, 2);
putenv(trim($name) . '=' . trim($value));
}
}
$apiKey = getenv('GEMINI_API_KEY');
$keys = explode(',', $apiKey);
$apiKey = trim($keys[0]);
$url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-lite-latest:generateContent?key={$apiKey}";
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['contents' => [['parts' => [['text' => 'hello']]]]]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);
$res = curl_exec($ch);
echo "Response: $res\n";