OpenAI has published an official command-line tool, openai, on GitHub. It calls the OpenAI REST API from your terminal or shell scripts, so you can generate images, upload files, submit batches and inspect API results without writing an app.
Commands follow the API's resources, in the form openai <resource> <command> [flags]. The README shows image generation (saved to a local folder), file upload and download, and batch jobs, where you upload a JSONL file, create the batch, then batches wait and download the results. Output is readable text by default, but you can ask for JSON or JSONL and pipe it into jq, or pull out fields with --transform. There is also an admin key route for things like organization usage.
It installs as a prebuilt binary for macOS, Linux and Windows, through Homebrew, or with go install (Go 1.26 or later). It is Apache 2.0 licensed. The README is clear that this is not Codex CLI: openai calls specific APIs, while codex is the coding agent.
My take
If you automate things, this is useful. I like running small jobs from a cron task or a script, and a batch workflow where one command waits and downloads results is exactly that kind of thing. Being able to pull usage data with one command and email it to yourself is the first thing I'd try.
Be careful with two details. First, the tool can auto-update itself during eligible interactive runs for self-managed installs. The README gives environment variables to turn that off, and on a production server I'd set OPENAI_CLI_NO_AUTO_UPDATE=1 before anything else. Second, the README warns that a failed request can leave an incomplete output file, so check the exit status before using redirected results. That is the kind of mistake that bites quietly in a script.
The OPENAI_UNTRUSTED_STDIN setting is also worth knowing: the @path syntax can read local files, so piping in JSON from an untrusted source without it is risky.
The README says nothing about availability or pricing beyond needing an API key, so I can't say anything about access for builders outside the US and Europe. Payment for the API itself is still the real hurdle for many of us. Still, a Go binary that installs in one line is a lower barrier than setting up a Python environment just to test an endpoint.
Sources
Drafted with AI assistance from the sources above, and reviewed before publishing.
Comments
What do you think? Drop your thoughts below.
Loading comments…