Nano Banana Pro API Debug"; if (!defined('GEMINI_API_KEY') || empty(GEMINI_API_KEY)) { die("
ERROR: API key not configured in config.php
"); } echo "API Key configured: Yes (ending in " . substr(GEMINI_API_KEY, -8) . ")
"; // Test API call $url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent"; $payload = [ 'contents' => [ ['parts' => [['text' => 'A simple red circle on white background']]] ], 'generationConfig' => [ 'responseModalities' => ['IMAGE'], 'imageConfig' => [ 'aspectRatio' => '1:1', 'imageSize' => '1K' ] ] ]; echo "URL: $url"; echo "
Payload: " . json_encode($payload, JSON_PRETTY_PRINT) . ""; echo "
HTTP Status Code: $httpCode
"; if ($curlError) { echo "cURL Error: $curlError
"; } echo ""; echo htmlspecialchars($response); echo ""; echo "
"; print_r($parsed); echo ""; // Check if image exists if (isset($parsed['candidates'][0]['content']['parts'])) { echo "
Parts found: " . count($parsed['candidates'][0]['content']['parts']) . "
"; foreach ($parsed['candidates'][0]['content']['parts'] as $index => $part) { echo "Part $index structure:
"; echo "" . print_r(array_keys($part), true) . ""; if (isset($part['inline_data']['data'])) { echo "
✓ Image data found in inline_data format!
"; echo "Data length: " . strlen($part['inline_data']['data']) . " characters
"; echo "✓ Image data found in inlineData format!
"; echo "Data length: " . strlen($part['inlineData']['data']) . " characters
"; echo "No image data in this part
"; } } } else { echo "ERROR: No candidates/content/parts found in response
"; if (isset($parsed['error'])) { echo "API Error: " . htmlspecialchars($parsed['error']['message'] ?? 'Unknown error') . "
"; echo "" . print_r($parsed['error'], true) . ""; } }