Skip to content

Instantly share code, notes, and snippets.

@simonw
Created February 13, 2025 03:46
Show Gist options
  • Save simonw/805ac8356312b43ff0b47e5bdc32f646 to your computer and use it in GitHub Desktop.
Save simonw/805ac8356312b43ff0b47e5bdc32f646 to your computer and use it in GitHub Desktop.
uv run --with pillow --with google-genai python -c '
import os
from google import genai
from google.genai import types
from io import BytesIO
from PIL import Image

GEMINI_API_KEY = os.environ["GEMINI_API_KEY"]

client = genai.Client(api_key=GEMINI_API_KEY)
response = client.models.generate_images(
    model="imagen-3.0-generate-002",
    prompt="a cozy cactus garden in half moon bay, california, four varied chickens, pixel art",
    config=types.GenerateImagesConfig(
        number_of_images=1,
    ),
)
image = Image.open(BytesIO(response.generated_images[0].image.image_bytes))
image.show()'
@simonw
Copy link
Author

simonw commented Feb 13, 2025

image

@gerrywastaken
Copy link

I wonder how many people couldn't spot the fourth chicken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment