GitHub - openai/openai-cli: Official CLI for the OpenAI API
This is the README for `openai`, an official command-line tool that wraps the OpenAI REST API so you can generate images, manage files, run batches, and script API calls without writing an app. It is separate from Codex CLI, which is a coding agent for working on projects.
- Covers images, files, batches, models, and admin endpoints, with output as readable text or JSON/JSONL for scripting.
- Authentication is via an API key in the environment (OPENAI_API_KEY), with a separate admin key for organization endpoints.
- Installs through GitHub Releases, Homebrew, or `go install` (Go 1.26+), and checks for updates without installing them automatically.
The openai CLI is a terminal front end to the OpenAI REST API, meant for one-off calls and shell scripts rather than building an application. It covers image generation (openai images generate saves output to ~/Downloads/gpt-images/ and prints the paths), file upload, download and listing, batch submission (upload a JSONL request file, create a batch against /v1/responses with a 24h completion window, then wait and pull results to a directory), and model listing. The README draws a clear line between this tool and Codex CLI: use openai when you want to call a specific API operation, and codex when you want an agent to read, edit, and debug code in a project.
Setup is straightforward but has a few details worth knowing. You can install via Homebrew (brew install openai/tools/openai), download a binary from GitHub Releases for macOS, Linux, or Windows, or build with go install, which requires Go 1.26 or later. Authentication uses OPENAI_API_KEY, and admin endpoints such as organization usage need a separate OPENAI_ADMIN_KEY. Commands follow a resource-then-subresource pattern, so the tool's structure mirrors the API. The CLI checks for updates on interactive runs but never installs them automatically, and OPENAI_CLI_NO_UPDATE_CHECK=1 turns the checks off.
The output and scripting details are where the practical value sits. Successful JSON is pretty-printed by default, --transform extracts fields using GJSON syntax, and errors go to stderr as summaries unless you ask for JSON with --format-error json. The author warns that a failed request can leave a partial output file, so check exit status before trusting redirected results, and that API error details and --debug logs may contain sensitive data. Input flags accept @path to read values from local files, and OPENAI_UNTRUSTED_STDIN=1 blocks piped input from triggering local file reads, which matters if you pipe JSON from anywhere you don't control. Shell completion and a command-insertion picker are included for Bash, zsh, fish, and PowerShell. Contributions are restricted to repository collaborators, so the practical route for outsiders is filing issues.