<?php
/**
 * Quick API Test - Direct execution
 */

echo "Testing Chat API v3...\n\n";

// Set test GET/POST parameters
$_GET['action'] = 'get_status';
$_SERVER['REQUEST_METHOD'] = 'GET';

// Capture output
ob_start();

try {
    require __DIR__ . '/auth-system/api/chat-ai-v3.php';
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

$output = ob_get_clean();
echo $output;

// Parse and validate JSON
$json = json_decode($output, true);
if ($json && $json['success']) {
    echo "\n✅ API is working!\n";
    echo "Status: " . ($json['connected'] ? 'Connected' : 'Not connected') . "\n";
    echo "Has API Key: " . ($json['connected'] ? 'YES' : 'NO') . "\n";
} else {
    echo "\n❌ API returned invalid response\n";
}
?>
