OpenAI CLI

Canonical version: OpenAI CLI.

The OpenAI CLI (openai) is "The official command-line tool for the OpenAI REST API", published by OpenAI in October 2026. It's a CLI for calling the API from a terminal or a shell script: generate images, upload files, submit batches, read usage. Apache 2.0, written in Go.

It isn't an agent. The README draws the line itself: use Codex to get work done, use openai "when you want to call a specific API or put API operations in a script". One HN commenter put it in two lines: "Codex = agent harness", "OpenAI CLI = wrapper around API".

How it works

Commands follow the API's resources: openai <resource> [subresource...] <command> [flags...].

openai responses create --model gpt-5.5 --input "Say this is a test"
openai models list --format jsonl | jq '.id'
openai images generate --prompt "A tiny orange robot watering a houseplant"
openai batches wait <batch-id> --output-dir ./results
openai admin organization usage completions
  • Output. Readable text by default, even in pipes. --format switches to json, jsonl, raw or yaml, and --transform extracts fields with GJSON paths, so you often don't need jq
  • Help. --help works on every command, without an API key or a network connection. That's the main argument for using it over curl
  • Auth. openai help setup walks you through storing the key. Scripts read OPENAI_API_KEY (admin endpoints use OPENAI_ADMIN_KEY). There's no login, so it bills API credits
  • Inputs. @path loads JSON or YAML from a file. Set OPENAI_UNTRUSTED_STDIN=1 when the input isn't yours
  • Coverage. Images (generated files go to ~/Downloads/gpt-images/), files, batches, streaming, vector stores, audio, a local tokenizer, webhook testing and shell completion
  • Debugging. --debug, --debug-body and --debug-sse. The README warns that these logs "can contain sensitive data"

Install it with brew install openai/tools/openai, go install github.com/openai/openai-cli/cmd/openai@latest (Go 1.26+) or a release binary. Release installs update themselves during interactive runs; OPENAI_CLI_NO_AUTO_UPDATE=1 turns that off. Pull requests are only accepted from collaborators.

Reception on Hacker News

The repo got 244 points and 111 comments (around 2026-10-22).

  • Naming. isodev found the overlap with Codex confusing. haaz thought the split made sense: one tool runs your API workspace, the other is a consumer agent product
  • Why not curl? gavinray posted near-identical curl calls. Replies pointed to discoverability and -h help, and jubilanti compared it to the GitHub CLI. td521534f12 noted that the curl version leaks the API key into the process list
  • Docs. yipinwong said the README never explains why or when to use it: "This is not AX (agent experience) friendly" (Agent Experience (AX))
  • Billing. albert_e asked whether it draws on a ChatGPT subscription or API credits, and nobody answered in the thread
  • A long side debate argued that an LLM could generate a wrapper like this in an afternoon, and whether such code can be trusted

My take

This belongs to the same wave as the Cloudflare CLI: vendors shipping one typed CLI over their whole API because agents drive shells better than they read API docs. For me, the value is --help without a network call and the JSON/JSONL output. An agent can discover the API and pipe results into the next step, without me pasting docs into the context.

I wouldn't use it for one-off chat (Codex or Simon Willison's llm do that better). Where I'd use it is batch jobs and usage reports in scripts, with the key in the environment instead of on the command line.

References


About Sébastien

Ready to get to the next level?

Found this valuable? Share it with someone who needs it.

Join 6,000+ readers. Get practical systems for knowledge & AI. Free.

Subscribe ✨

Free: Knowledge System Checklist

A clear roadmap to building your own knowledge system. Subscribe and get it straight to your inbox.

6,000+ readers. No spam. Unsubscribe anytime.

Subscribe