Skip to main content

LLM plugin for OpenAI gpt-image-1 image generation and editing

Project description

llm-openai-images

An LLM plugin providing access to gpt-image-1, OpenAI's latest image generation and editing model.

API Key Setup

You will need an OpenAI API key to use this plugin. Set it using:

llm keys set openai

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

Understanding the Output (Base64)

The plugin outputs raw base64 encoded data directly from the OpenAI API. This provides the unmodified data but requires an extra step to view or save.

You typically need to pipe the output through base64 --decode (available on most Linux/macOS systems) and redirect it to a file:

llm -m openai/gpt-image-1 "Prompt..." | base64 --decode > my_image.png

Usage

This plugin adds the openai/gpt-image-1 model to LLM.

Basic Image Generation

To generate an image from a text prompt:

llm -m openai/gpt-image-1 "A cat wearing sunglasses, riding a skateboard" \
  | base64 --decode > cat_skateboard.png

This command generates the image based on the prompt and saves the decoded PNG data to cat_skateboard.png.

Generation Options

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

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

Example with options:

llm -m openai/gpt-image-1 "Impressionist painting of a harbor at sunset" \
  -o size landscape -o quality high \
  | base64 --decode > 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 "Add a small blue bird perched on the cat's head" \
  -a cat_skateboard.png \
  | base64 --decode > cat_skateboard_with_bird.png

Combining Multiple Images

llm -m openai/gpt-image-1 "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 \
  | base64 --decode > my_fabulous_self.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.1.1.tar.gz (8.6 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.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_openai_images-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 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.1.1.tar.gz
Algorithm Hash digest
SHA256 86862a33c7df7b0d00af7426c590b2355e946ad97aa3a09062f881e5c7de92e1
MD5 7da4c9181d6afeef859c29025ccfbb1b
BLAKE2b-256 8e8e3729e704fbb1d5118cccb56baeee1e3cfade9175eaa4889eceefb2d9bea2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_openai_images-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d8b2a0817fb777b5df9ecc4b080be68c063f407492d4f851e6aca02474f5e18
MD5 0d0115a071e43afe332e1cffb5ef330f
BLAKE2b-256 90d72b9f64733169a23da9d590cafc0fb8f2020cf4f04bc0ea1675cdc7fb3167

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