[[ "parts" => [["text" => $prompt]] ]], "generationConfig" => ["responseModalities" => ["TEXT", "IMAGE"]] ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData)); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); $imageBase64 = ''; if (!empty($data['candidates'][0]['content']['parts'][0]['inlineData']['data'])) { $imageBase64 = $data['candidates'][0]['content']['parts'][0]['inlineData']['data']; } header('Content-Type: application/json'); echo json_encode(['image' => $imageBase64]); exit; } ?>
Posts