Skip to main content

Image Generation CLI

A command line interface for generating images. The intial focus will be on using the OpenAI API and gpt-image-2.

Install

Install with uv so image-gen is available on your PATH. From a clone of this repository:

uv tool install --editable .

Or install directly from GitHub:

uv tool install git+https://github.com/bwbensonjr/image-gen-cli

uv places the launcher in its tool-bin directory (typically ~/.local/bin). If image-gen is not found after install, run uv tool update-shell once and restart your shell, or check the location with uv tool dir --bin.

OPENAI_API_KEY (and optionally OPENAI_BASE_URL) must be set in your shell environment when invoking image-gen.

To upgrade after pulling new commits (non-editable installs):

uv tool upgrade image-gen-cli

Behavior

  • Accepts an overall prompt describing what is wanted
  • Optionally it can accept other inputs including
    • Markdown or text files
    • Example images
  • An output file name specification (defaults to "output-image")
  • The output is one or more images with names like "output-image-1.png" using the output file name spec.

Technical Guidelines

  • Use OpenAI Python API which will use environment variables for OpenAI key and base URL.
  • Use Python argparse.
  • Use clig.dev command line guidelines cached locally as docs/cli_guidelines.md.

OpenAI gpt-image-2 Use

The recommendation for using gpt-image-2 from the OpenAI API is shown in this example:

prompt = "Generate an image of Otter hugging a Penguin"
output_file = "image_output.png"
client = OpenAI() 
response = client.responses.create(
    model="gpt-5.5",
    input=prompt,
    tools=[{"type": "image_generation"}],
)
# Save the image to a file
image_data = [
    output.result
    for output in response.output
    if output.type == "image_generation_call"
]
if image_data:
    image_base64 = image_data[0]
    with open(output_file, "wb") as f:
        f.write(base64.b64decode(image_base64))

Metadata

Release files for image-gen-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for image-gen-cli 0.1.0
File Size Uploaded
image_gen_cli-0.1.0.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for image-gen-cli 0.1.0
File Interpreter ABI Platform
image_gen_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.1 kB

Release files / image_gen_cli-0.1.0.tar.gz

Download URL image_gen_cli-0.1.0.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ccd32a22c9c2277c7587ec4a12691af9f5073d6273ba431646fc6933d8de4960
BLAKE2b-256 checksum
How to use checksums
f95909893e7c5f8062b53ec1bde2e8eed72022870d906ddf702ce09aa725423d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / image_gen_cli-0.1.0-py3-none-any.whl

Download URL image_gen_cli-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
893827ae9047d9cbdfa4336610db528f2772efca3264ad0aa9233ba7e6c0611e
BLAKE2b-256 checksum
How to use checksums
9074f73d1fd6ce4af09d70f41bef9a09ca5cbdc8603ed6298bedc38fe219121a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page