OpenAI now ships an official command line tool, and it’s open source. The OpenAI CLI puts GPT models one short command away from your terminal, no browser tab required. It has been on GitHub since May, and it already has over a thousand stars.
What the OpenAI CLI actually is
The OpenAI CLI is the company’s official tool for talking to its API from a terminal. You type a command, the tool sends your request to OpenAI’s servers, and it prints the answer right below your prompt. That’s the whole idea.
A few things make it interesting, though:
- It’s official. OpenAI wrote it and maintains it, so it tracks the real API instead of guessing at it.
- It’s open source under the Apache 2.0 license. Anyone can read the code or fork it.
- It speaks plain English back. Successful JSON responses get printed as readable text by default, even inside pipes, so you don’t have to squint at raw brackets and quotes.
- It works with files, images, and admin usage reports, not just chat.
The command structure follows a simple pattern: openai <resource> <command> [flags]. Want a chat reply? openai responses create. Need an image? openai images generate. Everything branches from there, and every command has a full help page you can read without an internet connection.
If you’ve used Gemini’s CLI tool before, the shape will feel familiar. We compared the free approach in our guide on how to start coding with AI using Gemini CLI. The difference here is that the OpenAI CLI comes straight from OpenAI, so new model releases show up in it immediately.
Installing it takes about five minutes
Two main routes exist, and both are painless. Pick the one that matches your setup:
| Method | Best for | Command |
|---|---|---|
| Homebrew | Mac and Linux users | brew install openai/tools/openai |
| Go 1.26+ | People who already use Go | go install 'github.com/openai/openai-cli/cmd/openai@latest' |
On a Mac, Homebrew is the faster path. Run that one line, wait a moment, and you’re done. Go users get the binary dropped into $HOME/go/bin, and if your shell can’t find it afterward, you’ll need to add that directory to your PATH.
One thing I appreciate: the tool never updates itself. It checks GitHub release metadata at most once a day, prints a small notice if a new version exists, and otherwise leaves you alone. Paranoid about that? Set OPENAI_CLI_NO_UPDATE_CHECK=1 and it stops checking entirely.
Your first command
Before anything works, you need an API key. Grab one from platform.openai.com, then hand it to your terminal:
export OPENAI_API_KEY="sk-..."
Now the fun part:
openai responses create --input "Say this is a test" --model gpt-5.5
That’s it. The reply prints in plain text right under the command. Honestly, the first time it happened I laughed a little, because I’d been switching to a browser tab for this exact task for two years.
Want to make sure everything is set up right? Run openai help setup and the tool walks you through it. Help works without an API key and even without internet, so you can explore every command before spending a cent.
Everyday commands worth knowing
Here’s where the tool stops being a toy. These are the commands I’d actually use week to week.
Images. openai images generate --prompt "A tiny orange robot" generates a picture and saves it to ~/Downloads/gpt-images/, then prints the file path. It uses the gpt-image-2.5-sunburst model by default, and you can swap in another model with --model or name the output with --name. For blog thumbnails and quick mockups, this replaces the whole “open the site, click generate, download, move the file” dance.
Files. Upload, inspect, and download files without touching a dashboard:
openai files upload "notes.txt" --purpose user_data
openai files get file-example
openai files download file-example --output "copy.txt"
Upload takes a plain path, no @ prefix, which sounds minor until you’ve fat-fingered the wrong syntax three times in a row.
Usage reports. Admin types can pull API usage with openai admin organization usage completions plus a start time, end time, and bucket width. If you manage a team’s OpenAI bill, this is the fastest way to see who’s burning tokens. It needs a separate admin key from the same settings page.
Scripts. Add --format json or --format jsonl when another program needs to read the output. This detail matters more than it looks, because readable text is nice for humans and terrible for scripts. OpenAI split the difference: pretty by default, strict when you ask.
Using it for real automation
Here’s the beginner-friendly superpower. Because the OpenAI CLI is just a program, anything that can run programs can use it: cron jobs, shell scripts, Zapier’s code steps, you name it.
A practical example. Say you keep a folder of downloaded receipts and want a one-line summary of each. A five-line shell script can loop through the folder, run openai responses create on every file, and append the summaries to a log. Total cost: fractions of a cent. Total setup time: maybe twenty minutes the first time.
Shell completion makes this nicer too. The tool supports Tab completion in Bash, zsh, and fish, and there’s a command insertion mode that fills your command line from built-in examples. Press Ctrl+X then Tab and it suggests completions without running them. Small thing. But it lowers the “wait, what was the flag again?” friction that kills most CLI habits.
If this hooks you on terminal AI generally, we’ve got a full walkthrough of coding with Gemini’s CLI too, since Google ships a similar free tool. Between the two, most beginner automation jobs are covered without writing an app. And if you’d rather automate without touching code at all, our n8n self-hosted assistant tutorial shows the one-line setup route.
What it costs
The OpenAI CLI itself is free. The API calls underneath are not.
Every command hits the paid OpenAI API, so you pay the normal token rates for whatever model you pick. There’s no subscription bundled in and no free tier for the API beyond trial credits. For light use, like a few summaries or images a day, the bill is usually pocket change. Heavy batch jobs are where costs climb, so run one test before you point a script at a thousand files.
As a result, the honest framing is this: the tool is free, the habit has a meter running. Watch your usage page the first week and you’ll know exactly what your workflows cost.
Should you bother learning it?
If you live in a terminal already, yes, and it’s not close. The OpenAI CLI removes an entire context switch from your day, and official tooling means fewer surprises when models change. The full source lives at github.com/openai/openai-cli, and the API reference is at platform.openai.com/docs if you want the complete picture.
If you’ve never opened a terminal on purpose, this is still one of the friendliest entry points I’ve seen. Help is built in, mistakes are cheap, and the skill transfers to every other CLI you’ll ever touch. Start with the image command, since the output is a file you can actually see, then work your way up to scripts.
Either way, five minutes of setup buys you a permanently faster path to GPT. That trade is hard to beat.