← all repositories
openai/openai-cli

OpenAI ships an official CLI, and it's actually scriptable

A Go terminal tool for the OpenAI REST API that treats shell scripting as a first-class use case, not an afterthought.

★1.1k stars Go Other AI
openai-cli
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

The openai CLI wraps the OpenAI REST API in terminal commands: generate and save images, upload and download files, submit batches and wait for results, list models, pull admin usage stats. Commands mirror the API’s resource structure, so if you know the REST endpoints you already know the command names. It’s the official tool, written in Go, with prebuilt binaries for macOS, Linux, and Windows.

The interesting bit

The output design is the part most CLIs get wrong. Successful responses print readable text by default — even in pipes — and you opt into --format json or jsonl only when you actually want to parse. There’s --transform with GJSON syntax for pulling a single field, --format-error json for machine-readable errors, and a @path convention for reading JSON input from files. Someone thought about shell scripts as real users.

Key highlights

  • Image generation saves files locally (default ~/Downloads/gpt-images/) and previews in supported terminals
  • Batch workflow: upload a JSONL file, create the batch, batches wait blocks until results are ready to download
  • Local tokenizer and webhook-testing utilities that work without an API key
  • OPENAI_UNTRUSTED_STDIN=1 blocks piped input from triggering local file reads — a rare, thoughtful security touch
  • Shell completion plus Ctrl+X example search that inserts commands without running them

Caveats

  • The README is explicit that this is not an agent: for code-editing work, use Codex CLI instead
  • No pull requests from non-collaborators — issues only
  • Update checks phone home on interactive runs (disable with OPENAI_CLI_NO_UPDATE_CHECK=1)

Verdict

If you’re gluing OpenAI API calls into shell scripts or just want to poke at an endpoint without writing a throwaway Python file, this earns a spot on your PATH. If you wanted a chat interface or a coding agent, it’s the wrong binary — and the README says so itself.

Frequently asked

What is openai/openai-cli?
A Go terminal tool for the OpenAI REST API that treats shell scripting as a first-class use case, not an afterthought.
Is openai-cli open source?
Yes — openai/openai-cli is open source, released under the Apache-2.0 license.
What language is openai-cli written in?
openai/openai-cli is primarily written in Go.
How popular is openai-cli?
openai/openai-cli has 1.1k stars on GitHub.
Where can I find openai-cli?
openai/openai-cli is on GitHub at https://github.com/openai/openai-cli.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.