Skip to contents

bananarama generates slide backgrounds with Google Gemini. Define your images in a YAML configuration file with support for reference images and style defaults, then generate images in parallel, making it fast to generate full deck of images.

bananarama avoids the usual tedious loop of copying prompts into a web UI, downloading images, tweaking, and repeating. Now your process is (mostly) reproducible: your prompts live in version-controlled YAML, and regenerating every image is a single function call. No more copy-paste and no more losing track of which prompt produced which image.

Installation

You can install the development version of bananarama from GitHub:

# install.packages("pak")
pak::pak("hadley/bananarama")

Usage

Create a bananarama.yaml file that describes the images you want to generate:

defaults:
  style: >
    Flat vector editorial illustration with a muted, desaturated
    color palette. Mid-century modern aesthetic. Calm and approachable.

images:
  - name: robot-factory
    description: >
      Draw a picture of [hadley] overseeing a factory full of robots.
      The robots should be typing at computers.

Reference images like [hadley] are matched to image files (e.g. hadley.png) in the same directory as the YAML file.

Then generate the images with:

bananarama::bananarama("path/to/bananarama.yaml")

Images that already exist are skipped unless you pass force = TRUE.

Bananarama currently uses nano banana2 (aka gemini-3.1-flash-image-preview), which costs around $0.07 per image.

YAML configuration

defaults

  • style: Style prompt appended to every image description. Use this to ensure a consistent style across all slides.
  • description: Default description; not usually needed unless you want to experiment with styles.
  • aspect-ratio: One of "1:1", "3:2", "16:9", etc. Default: "16:9".
  • resolution: One of "1K", "2K", "4K". Default: "1K".
  • n: Number of variants to generate per image. Default: 1.
  • model: Image model to use (see below). Default: "gemini-3.1-flash-image-preview" (aka nano banana2).
  • force: If true, regenerate images even if they already exist. Default: false.
  • seed: Integer seed for the random number generator. Makes output more (but not perfectly) deterministic. Gemini models only; ignored (with a warning) for OpenAI models.

Supported models

The provider is inferred from the model name. Supported models:

  • Gemini
    • gemini-3.1-flash-image-preview (default)
    • gemini-3.1-flash-lite-image
    • gemini-3-pro-image
  • OpenAI
    • gpt-image-2.5-flare (fast)
    • gpt-image-2.5-sunburst (higher quality)

OpenAI models require the OPENAI_API_KEY environment variable. Images are generated via the Responses API, so reference images ([name] placeholders) work with both providers. One limitation compared to Gemini: seed is not supported.

OpenAI models are much slower than gemini models.

output-dir

Output directory for generated images, relative to the YAML file. Defaults to a directory with the same name as the YAML file (e.g. bananarama.yaml outputs to bananarama/).

images

Each image has:

  • name (required): Used as the output filename ({name}.png).
  • description (required, unless a default is set): Prompt for image generation. Use [name] to reference images in the same directory.
  • sequence: A list of steps that build on one another; see vignette("sequence", package = "bananarama"). Mutually exclusive with description.
  • n: Number of variants to generate. Output files are named {name}-1.png, {name}-2.png, etc. Default: 1.
  • style, aspect-ratio, resolution, model, force, seed: Per-image overrides of the defaults.