Skip to main content

LLM plugin for OpenAI and Google image generation and editing

Project description

llm-openai-images

PyPI

An LLM plugin providing access to OpenAI's gpt-image-1.5 and Google's Nano Banana models for image generation and editing.

Installation

Install this plugin in the same environment as LLM.

llm install llm-openai-images

API Key Setup

You will need API keys for the providers you want to use.

OpenAI:

llm keys set openai

Enter your key when prompted. You can obtain a key from the OpenAI Platform.

Google (Gemini API):

llm keys set gemini

Enter your key when prompted. You can obtain a key from Google AI Studio.

Output Files

The plugin writes images to files and prints the output path. By default, files are written to the current working directory using this naming scheme:

<model>_<timestamp>.png

To override the output path, use -o output:

llm -m openai/gpt-image-1.5 "Prompt..." -o output path/to/file.png

Usage

This plugin adds the following models to LLM:

  • openai/gpt-image-1.5
  • google/nano-banana
  • google/nano-banana-pro

Basic Image Generation

To generate an image from a text prompt:

llm -m openai/gpt-image-1.5 "A cat wearing sunglasses, riding a skateboard"

Generation Options

You can control the image size and quality using options (-o):

  • -o size <value>: Set the image dimensions.
    • square (default): 1024x1024
    • portrait: 1024x1536
    • landscape: 1536x1024
  • -o quality <value>: Set the image quality/detail.
    • high: ~$0.26
    • medium (default): ~$0.06
    • low: ~$0.015

These options apply to openai/gpt-image-1.5 only. Google Nano Banana models currently ignore them.

For Google Nano Banana models, you can set:

  • -o aspect_ratio <value>: Set the image aspect ratio (default: 1:1).
    • 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9

Example with options:

llm -m openai/gpt-image-1.5 "Impressionist painting of a harbor at sunset" \
  -o size landscape -o quality high \
  -o output harbor_sunset_hd_landscape.png

Editing an Image

To edit an existing image, provide the image file as an attachment using the -a or --attach flag. The prompt should describe the desired changes or additions to the image.

# First, generate an image or use an existing one (e.g., cat_skateboard.png from above)

# Now, edit it:
llm -m openai/gpt-image-1.5 "Add a small blue bird perched on the cat's head" \
  -a cat_skateboard.png \
  -o output cat_skateboard_with_bird.png

Combining Multiple Images

llm -m openai/gpt-image-1.5 "A photo of me dressed in these pants and top" \
  -a maison-martin-margiela-ss16-blouse.jpg \
  -a dior-homme-19cm-mij.jpg \
  -a me.jpg \
  -o output my_fabulous_self.png

Nano Banana (Google) Examples

llm -m google/nano-banana "A kitten with prominent purple-and-green fur."
llm -m google/nano-banana-pro "A cinematic portrait of a hummingbird" \
  -o output hummingbird.png

Development

To set up this plugin locally, first checkout the code. Then install it in editable mode:

cd llm-openai-images
llm install -e .

See the LLM plugin documentation for more details on plugin development.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_openai_images-0.3.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_openai_images-0.3.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file llm_openai_images-0.3.1.tar.gz.

File metadata

  • Download URL: llm_openai_images-0.3.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for llm_openai_images-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2e25cbf8cbdcf9bf017e2c6b7e183dc9cf570794e989209353d6d2effb10d60b
MD5 9d4959d1866541093b4e26bb68335e00
BLAKE2b-256 4f10a18ad31464fa6754df831dd1c42c9b284c6a17884f1258cdb029017f9f21

See more details on using hashes here.

File details

Details for the file llm_openai_images-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_openai_images-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60b0a6bbf5e49a7292d5adb545b2bceedd91ed13aa98dfae9d736e251b9bc27b
MD5 a183ddc45e1d1d6f0e799b22805a6966
BLAKE2b-256 85b12a161f44641a2e2f43085fbb68c3aaf6d4c65574e4c09f57203a879531bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page