Skip to content

Instantly share code, notes, and snippets.

@peterc
Created November 17, 2025 15:41
Show Gist options
  • Select an option

  • Save peterc/d6683cce1f11abbf25393c02ef6c5265 to your computer and use it in GitHub Desktop.

Select an option

Save peterc/d6683cce1f11abbf25393c02ef6c5265 to your computer and use it in GitHub Desktop.
Produce images with gemini-2.5-flash-image (Nano Banana) with RubyLLM 1.9.1
# Just because the example in the docs doesn't seem to work outside of a Rails app
require 'ruby_llm'
RubyLLM.configure do |config|
config.gemini_api_key = ENV['GEMINI_API_KEY']
end
chat = RubyLLM.chat(model: "gemini-2.5-flash-image")
reply = chat.ask("Cyberpunk city street at night, raining, neon signs")
image = reply.content[:attachments].first
image.save("output.png")
@peterc
Copy link
Author

peterc commented Nov 17, 2025

Still can't establish how to send the aspect ratio information as in the Google example though:

response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents=[prompt, image],
    config=types.GenerateContentConfig(
        response_modalities=["IMAGE"],
        image_config=types.ImageConfig(
            aspect_ratio="16:9",
        )
    )
)

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