Skip to content

Instantly share code, notes, and snippets.

@GeroZayas
Created December 28, 2025 09:40
Show Gist options
  • Select an option

  • Save GeroZayas/2cac4834ae8bf590acb539c60c0fc854 to your computer and use it in GitHub Desktop.

Select an option

Save GeroZayas/2cac4834ae8bf590acb539c60c0fc854 to your computer and use it in GitHub Desktop.
Generate Image with Gemini 3 model
from google import genai
client = genai.Client(api_key=GEMINI_API_KEY)
def generate_image(prompt: str) -> None:
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=prompt,
config=genai.types.GenerateContentConfig(
response_modalities=["IMAGE"],
image_config=genai.types.ImageConfig(
aspect_ratio="9:16"
),
),
)
for part in response.parts:
if part.inline_data:
part.as_image().show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment