Created
December 28, 2025 09:40
-
-
Save GeroZayas/2cac4834ae8bf590acb539c60c0fc854 to your computer and use it in GitHub Desktop.
Generate Image with Gemini 3 model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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