Skip to main content

Command-line tool for generating images via the OpenAI API.

Project description

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))

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

image_gen_cli-0.1.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

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

image_gen_cli-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file image_gen_cli-0.1.0.tar.gz.

File metadata

  • Download URL: image_gen_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for image_gen_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ccd32a22c9c2277c7587ec4a12691af9f5073d6273ba431646fc6933d8de4960
MD5 6f5f48c87ff3e7fa7a34fd347892c10c
BLAKE2b-256 f95909893e7c5f8062b53ec1bde2e8eed72022870d906ddf702ce09aa725423d

See more details on using hashes here.

File details

Details for the file image_gen_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: image_gen_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for image_gen_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 893827ae9047d9cbdfa4336610db528f2772efca3264ad0aa9233ba7e6c0611e
MD5 12921f0ad63235627a67bba964b608ad
BLAKE2b-256 9074f73d1fd6ce4af09d70f41bef9a09ca5cbdc8603ed6298bedc38fe219121a

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