A few days ago I was curious to try out OpenAI APIs, so I wrote a small CLI tool to generate images using the API. The project can be found on this repository on GitHub.
Where can this be used?
You can easily generate unique cool images in a few seconds based on your thoughts and share them with your colleagues or friends on Slack, Twitter, or other social media!
How to install and use the tool
The instructions are written on the repository's README file at this link, but I will write a few ways to run it. The command will generate an image based on the prompt you pass to it and the size it should have and returns the URL of it.
Example command
The command is pretty simple. You can use it like this:
# If Go is installed locally
go run main.go -p "Dancing cat singing in a digital ocean" -s "1024x1024"
# If Go is not installed locally, but Docker is installed
docker run -it --rm -v $(pwd):/app -w /app golang:1.16 go run main.go -p "Dancing cat singing in a digital ocean" -s "1024x1024"
You can even build the project and create an alias on your laptop to call this command from anywhere in your terminal!
# 1. Build the project (run it while you are in this path)
go build -o open-ai-image-generate
# 2.1. You can create an alias like this (if you prefer not to build the project)
alias 'open_ai_generate_image=docker run -it --rm -v /path/to/cloned/repo:/app -w /app golang:1.16 go run main.go'
# 2.2. You can create an alias like this (if you have also built the project)
alias 'open_ai_generate_image=/path/to/cloned/repo/open_ai_generate_image'
# 3. Then you can run it like this
open_ai_generate_image -p "Dancing cat singing in a digital ocean" -s "1024x1024"
Alternatively, you can:
- Copy the executable to your
$PATH(for example,/usr/local/binor/usr/bin) and call it from anywhere in your terminal, or you can add the project's directory to your$PATH. - Run go install to install the project in your
$GOPATHand call it from anywhere.
If you install the application using the go install command, remember to:
- Add your
$GOPATHto your$PATHif you haven't already. - Set the
OPENAI_API_KEYenvironment variable with the value of your API key.

