27 lines
881 B
Python
27 lines
881 B
Python
import requests
|
|
import json
|
|
import base64
|
|
|
|
API_KEY = "AQ.Ab8RN6JRC8vPh-vLzItUVeS4vCofqzMf9TyF6Ce6BXw-Y18GuA"
|
|
# Use Interactions API format if needed, but let's try the standard endpoint first.
|
|
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image:generateContent?key={API_KEY}"
|
|
|
|
payload = {
|
|
"contents": [{
|
|
"parts": [{"text": "A simple square headshot portrait of Karyla. Style: painterly game concept art."}]
|
|
}]
|
|
}
|
|
headers = {'Content-Type': 'application/json'}
|
|
|
|
response = requests.post(url, headers=headers, json=payload)
|
|
print(response.status_code)
|
|
if response.ok:
|
|
data = response.json()
|
|
try:
|
|
# gemini-3.1-flash-image might return images in a different structure
|
|
print(json.dumps(data)[:200])
|
|
except Exception as e:
|
|
print("Failed to parse response:", data)
|
|
else:
|
|
print(response.text[:500])
|