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.
--formatswitches tojson,jsonl,raworyaml, and--transformextracts fields with GJSON paths, so you often don't need jq - Help.
--helpworks on every command, without an API key or a network connection. That's the main argument for using it overcurl - Auth.
openai help setupwalks you through storing the key. Scripts readOPENAI_API_KEY(admin endpoints useOPENAI_ADMIN_KEY). There's no login, so it bills API credits - Inputs.
@pathloads JSON or YAML from a file. SetOPENAI_UNTRUSTED_STDIN=1when 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-bodyand--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
curlcalls. Replies pointed to discoverability and-hhelp, and jubilanti compared it to the GitHub CLI. td521534f12 noted that thecurlversion 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
- Source code: https://github.com/openai/openai-cli
- Hacker News discussion: https://news.ycombinator.com/item?id=50191507
Related
- OpenAI
- Codex CLI
- OpenAI Codex
- Cloudflare CLI
- GitHub CLI
- Command Line Interface (CLI)
- Agent Experience (AX)
- jq
- Go
- Cloudflare Forge
- llm CLI
About Sébastien
Ready to get to the next level?
Found this valuable? Share it with someone who needs it.