26 lines
583 B
PHP
26 lines
583 B
PHP
<?php
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
|
|
// Adjust path if needed
|
|
require __DIR__ . '/app/Services/GeminiService.php';
|
|
|
|
$apiKey = getenv('GEMINI_API_KEY');
|
|
if (empty($apiKey)) {
|
|
// try to load from .env
|
|
$env = parse_ini_file(__DIR__ . '/.env');
|
|
$apiKey = $env['GEMINI_API_KEY'] ?? '';
|
|
}
|
|
|
|
if (empty($apiKey)) {
|
|
echo "NO API KEY FOUND\n";
|
|
exit;
|
|
}
|
|
|
|
echo "Testing Gemini API...\n";
|
|
$res = \App\Services\GeminiService::generateResponse($apiKey, "You are a helpful bot.", "hi");
|
|
if ($res) {
|
|
echo "SUCCESS: " . $res . "\n";
|
|
} else {
|
|
echo "FAILED.\n";
|
|
}
|