"OpenAI released a CLI" is only half right. Version 1.40.0 did appear on GitHub on October 21, 2026, but the CLI was not new that day. The first release, v1.0.0, shipped on May 5, 2026. v1.40.0 is a point release in that line.
The release notes are small, too. They list api: add custom voice consent management and api: clarify cache-write token totals. If you were waiting for a new product, that is underwhelming. If you want to put API operations into repeatable shell scripts, the release is a reminder that the command surface has been stable enough to build on.
What actually changed in v1.40.0
| Item | Detail |
|---|---|
| Release | v1.40.0, October 21, 2026, 08:41 UTC |
| Change 1 | Added custom voice consent management API |
| Change 2 | Clarified cache-write token totals |
| First release | v1.0.0, May 5, 2026 |
| Repository | openai/openai-cli |
| License | Apache-2.0 |
| Implementation | Go 1.26 or later; macOS, Linux, and Windows binaries |
The important fact is that this CLI has kept a fairly narrow scope for months: it is the official command-line adapter for the OpenAI REST API. v1.40.0 adds a voice-consent API surface and fixes token accounting language. It is not a new agent product or a model launch.
OpenAI CLI is not Codex CLI
The official README draws a clean line between the two tools.
| Question | OpenAI CLI | Codex CLI |
|---|---|---|
| Purpose | Call a specific API from the terminal or a script | Work on a codebase as a coding agent |
| Unit of work | openai <resource> <command> |
An interactive codex task |
| Typical jobs | Images, files, batches, model lists, usage | Read and edit code, run commands, debug |
| Best fit | Batch jobs, automation, collecting API results | Implementation, refactoring, tests |
Both live in a terminal, but they are different layers. OpenAI CLI is an API adapter. Codex CLI is an agent that acts on files and commands. The distinction matters because their permissions and failure modes are different. An API CLI has relatively explicit inputs and outputs. A coding agent can change a repository.
What the CLI exposes
The command tree mirrors the API's resources.
openai <resource> [subresource...] <command> [flags...]
openai images generate --prompt "..."
openai files upload report.txt --purpose user_data
openai files get file-example
openai files download file-example --output downloaded-report.txt
openai batches create --input-file-id file-example --endpoint /v1/responses --completion-window 24h
openai batches wait batch_example --output-dir ./results
openai models list --format jsonl
openai responses create --model "$MODEL" --input @prompt.txt
There are three installation paths: a prebuilt binary from GitHub Releases, Homebrew (brew install openai/tools/openai), or Go (go install github.com/openai/openai-cli/cmd/openai@latest). Authentication can use the guided openai help setup flow or the OPENAI_API_KEY environment variable for scripts. Admin endpoints use a separate OPENAI_ADMIN_KEY.
One subtle default: successful JSON responses are rendered as readable text, even in a pipe. If a script needs structured data, specify --format json, jsonl, raw, or yaml. The CLI also supports --transform with GJSON syntax for extracting a field.
Why put API work in a shell at all?
The fastest way to call an API is often an interactive tool or an SDK. Repeated operations have different requirements. Can you run the same procedure with the same input again? Does it stop on failure? Where does the result land? Those questions matter more than saving a few keystrokes.
The CLI's value is that it makes the procedure explicit. A batch job becomes a sequence: upload a JSONL request file, create a batch, wait for completion, download results, validate the JSON, and reprocess only the failures. That is slower to set up than clicking through a console, but far more predictable in CI or a scheduled job.
A safer batch script
The script below was not executed for this article. It uses no paid API calls, and response field names should be checked against your CLI version's --help. The point is the shape: no key on the command line, stop on failure, and narrow file permissions.
#!/usr/bin/env bash
set -euo pipefail
umask 077
: "${OPENAI_API_KEY:?set OPENAI_API_KEY in the environment}"
: "${MODEL:?set MODEL to a model returned by: openai models list}"
export OPENAI_CLI_NO_UPDATE_CHECK=1
# 1) Upload the input file
file_id="$(
openai files upload requests.jsonl \
--purpose batch \
--format json | jq -r '.id'
)"
# 2) Create the batch
batch_id="$(
openai batches create \
--input-file-id "$file_id" \
--endpoint /v1/responses \
--completion-window 24h \
--format json | jq -r '.id'
)"
# 3) Wait and download the results
openai batches wait "$batch_id" --output-dir ./results
# 4) Continue only after the result file exists and is non-empty
test -s "./results/${batch_id}/output.jsonl"
set -euo pipefail surfaces command failures early. umask 077 makes result files readable only by the owner. OPENAI_CLI_NO_UPDATE_CHECK=1 keeps update checks out of a CI network path. --format json and jq capture the file and batch identifiers for later commands.
There are limits. The CLI prints successful JSON as readable text by default; specify a format when parsing. Errors go to stderr. A failed request can leave an incomplete output file, so check the exit status before using a redirect as evidence of success. --debug and detailed API errors can contain sensitive data; do not ship them to a shared log without review.
Cost and operational boundaries
The official README does not describe a cost estimator. The completion window, model choice, input size, and retry count are operational decisions. Keep those decisions outside the script where possible.
| Control | Why it matters |
|---|---|
| Do not hardcode the model list | Use openai models list to see current availability |
| Limit input file size | Prevents accidental large uploads |
| Bound completion windows and retries | Avoids open-ended waits and duplicate charges |
| Separate admin and regular keys | Use OPENAI_ADMIN_KEY only for usage and admin calls |
| Restrict result directory permissions | Responses can contain sensitive data |
| Check usage before and after | openai admin organization usage can reveal anomalies |
Organization usage requires separate admin access. The README's example for daily buckets looks like this:
openai admin organization usage completions \
--start-time 1735689600 \
--end-time 1735776000 \
--bucket-width 1d
Do not treat that output as a billing statement. API prices and billing units change; verify them separately. The token totals shown by the CLI are not a guarantee that the invoice will match to the cent.
Where credentials leak
A CLI puts an API key in the shell environment. That is convenient, and it creates new paths for exposure.
- A key passed as a command-line argument can end up in shell history and the process list.
set -xor verbose debug logging can print environment variables.--debugand detailed API errors may include request headers or bodies.- CI jobs that print
envcan expose the key. - Result files can contain customer data or model output.
The safer pattern is to inject the key from a secret manager into the process environment, not the command line. Keep shell tracing off, avoid debug prints that include credentials, and scope the key to the job. In CI, inject it only into the step that needs it and clean up temporary files afterward.
What the CLI does not do
OpenAI CLI is not a general agent. The README explicitly points coding work to Codex CLI. The openai binary does not read a repository, decide which files to edit, run tests, or iterate on a fix. It calls API resources. It also does not validate the quality of the result. Batch output still needs schema validation and sample review.
This review did not run a paid API request, batch, image generation, or file upload. Commands and options come from the official README and the v1.40.0 release notes. Treat the script as a template to test in your own environment, not as a verified production recipe.
Conclusion: look at the command surface, not the version number
v1.40.0 is not a headline release. The durable value is that the CLI turns API operations into commands: uploads, batches, model lists, images, and usage queries. That makes them easier to review, rerun, and audit than a sequence of console clicks.
Before adopting it, decide three things. Which model and completion window belong in configuration rather than code? How will the key be separated from logs and shell history? What schema and retention policy will validate the result files? Without those, the CLI is a convenient caller, not an operable pipeline.
Further reading
- Codex CLI 0.161.0: MCP Login Arrives in the Terminal
- What Is the OpenAI Agents API? The Codex Harness as an API
References
Go deeper with a course
The product is different, but the discipline is the same: make AI work in a terminal repeatable, constrain permissions, and put verification around each step. If you want practice turning commands and project rules into a controlled workflow, this course is a useful next step.