tts-voice-creator-clone-and.../scratch/test_google_imagen.py

21 lines
670 B
Python

import requests
import json
import base64
API_KEY = "AIzaSyD6aidNxIhr2SKgauZ9zea_FynuCo2DyDo"
url = f"https://generativelanguage.googleapis.com/v1beta/interactions"
payload = {
"model": "gemini-3.1-flash-image",
"input": [{"type": "user_input", "content": [{"type": "text", "text": "A beautiful square headshot portrait of Karyla. Style: painterly game concept art."}]}],
"response_modalities": ["image"]
}
headers = {'x-goog-api-key': API_KEY, 'Content-Type': 'application/json'}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
if response.ok:
print("Success! Got image")
else:
print(response.text[:500])