Explainer

OpenAI CLI explained: what OpenAI's official command-line tool does, and how it differs from Codex CLI

The OpenAI CLI is OpenAI's official `openai` command for calling its API from a terminal: Responses, files, images, audio and admin endpoints, with an API key. Codex CLI is a coding agent. How to install the OpenAI CLI, what it covers and how the two tools differ, as of October 23, 2026.

A terminal with one lit command and one arrow to an API box beside a terminal in a dashed sandbox with a three-step loop, on mint, titled Not Codex

In 20 seconds

  1. The OpenAI CLI (github.com/openai/openai-cli) is 'the official command-line tool for the OpenAI REST API,' written in Go and licensed under Apache 2.0. It installs as a prebuilt binary, with `brew install openai/tools/openai` or with `go install`, and reads your key from OPENAI_API_KEY.
  2. It isn't new: its GitHub releases begin with v1.0.0 on May 5, 2026, and run through v1.40.5 on October 23, 2026, adding the Live API, image tools and admin-key setup along the way.
  3. It sends one API request per command, for Responses, files, images, speech, transcription and admin endpoints. Codex CLI, installed as `codex`, is a coding agent that edits code and runs commands inside a sandbox and can sign in with a ChatGPT plan.
On this page

The OpenAI CLI is OpenAI's official command-line tool for its API: a single openai binary that turns each API endpoint into a terminal command, such as openai responses create. It has shipped since May 2026, with version 1.40.5 released on October 23, 2026, and it's easy to confuse with Codex CLI, OpenAI's other terminal tool. The difference: the OpenAI CLI sends API requests you write yourself, while Codex CLI is an agent that decides what to do in your code.

This explainer is based on the openai-cli GitHub repository and changelog, OpenAI's OpenAI CLI documentation, the Codex GitHub repository and OpenAI's Codex CLI and sandboxing documentation, checked October 23, 2026. For how Codex itself works and what it costs, see our Codex explainer.

The short version

  • What it is: "The official command-line tool for the OpenAI REST API," per its README. Written in Go, Apache 2.0 licensed, copyright 2026 OpenAI.
  • Install: a prebuilt binary from GitHub Releases, brew install openai/tools/openai, or go install.
  • Sign-in: an API key in OPENAI_API_KEY; an admin key in OPENAI_ADMIN_KEY for admin endpoints. No ChatGPT sign-in is documented.
  • What it covers: Responses, files, batches, images, speech, transcription and organization admin endpoints, among others.
  • Not new: releases since May 2026; v1.40.5 on October 23, 2026.
  • Not Codex: Codex CLI is a coding agent with a sandbox; the OpenAI CLI makes no decisions of its own.

What is the OpenAI CLI?

It's a thin terminal client for the OpenAI API. Commands follow the API's resources, openai <resource> [subresource...] <command> [flags...], so openai files list lists your uploaded files and openai responses create --input "Say this is a test" --model gpt-5.5 sends one request to the Responses API. OpenAI's documentation pitches it for "one-off terminal requests" and for scripts that do "repeatable batch work over files and generated artifacts."

Output is controlled with --format, which accepts auto, json, jsonl, pretty, raw, yaml or explore (the repository's CLI reference also lists text). The default is readable text, "even in pipes," so scripts should ask for json or jsonl. A --transform flag pulls out fields with a GJSON path, so a script can keep only the assistant's text instead of the whole response object. Binary uploads take a plain file path, and JSON input flags can read a value from a file with @path.

How do you install the OpenAI CLI?

The README lists three methods:

  1. Prebuilt binary: download the archive for macOS, Linux or Windows from GitHub Releases and put openai on your PATH.
  2. Homebrew: brew install openai/tools/openai
  3. Go: go install 'github.com/openai/openai-cli/cmd/openai@latest'. The binary lands in $HOME/go/bin by default. The README now asks for Go 1.26 or later, while OpenAI's documentation page still says Go 1.25.

From a clone of the repository, ./scripts/run runs it without installing. No npm or pip package is documented. The CLI checks for updates on interactive runs but never installs them itself; OPENAI_CLI_NO_UPDATE_CHECK=1 turns the checks off.

How does the OpenAI CLI sign in?

With API keys. openai help setup walks you through entering one, and scripts can supply it as an environment variable. Standard endpoints use OPENAI_API_KEY; admin endpoints use OPENAI_ADMIN_KEY, and OpenAI's docs say the right key is selected "based on the endpoint being called." Other variables set the organization, project, a webhook secret and mutual TLS certificates; the repository's CLI reference says mutual TLS "is currently in beta." OPENAI_BASE_URL points it at a different API host.

Two cautions from OpenAI: its docs say to "be careful about giving unvetted actors access to admin keys," and --debug prints request and response details. The CLI reference warns: "do not share debug logs if they may contain sensitive payloads."

Because it uses an API key, each command is a normal API call billed to that key's organization. There's no documented way to sign in with a ChatGPT plan.

What can the OpenAI CLI do?

OpenAI's documentation walks through these areas:

  • Responses: text generation, structured JSON output, web search and file inputs, with models such as gpt-6-astra and gpt-5.5.
  • Files and batches: uploads for use as Responses inputs, and batch jobs the CLI can wait on and download.
  • Images: openai images generate and openai images edit, with gpt-image-2. The README says generated images are saved to ~/Downloads/gpt-images/ (or a folder set with --output-dir); OpenAI's documentation page still says image commands "do not yet have native --output support" and decodes base64 output instead.
  • Speech: openai audio:speech create with gpt-4o-mini-tts, written to a file such as MP3. OpenAI's docs mark that model deprecated, with shutdown on January 6, 2027.
  • Transcription: openai audio:transcriptions create with gpt-transcribe, the model the docs recommend, for plain transcript text. whisper-1 (for srt and vtt subtitles) and gpt-4o-transcribe-diarize still work but shut down on February 26, 2027.
  • Admin: openai admin organization commands (the older admin:organization:* form also works) to manage projects and service accounts and fetch usage.

The README doesn't list every supported endpoint; it points to --help, which works without an API key or network connection, and to a CLI reference. The changelog shows coverage growing fast: the Live API arrived in v1.15.0 on September 10, an inline image-generation picker in v1.33.0 on October 3, usage cost grouping in v1.38.0 on October 8, admin-key setup, voice creation and batch downloads in v1.39.0 on October 19, and speech playback, live microphone translation, a local command search (openai explore) and webhook setup in v1.40.3 on October 22, 2026.

Is the OpenAI CLI the same as Codex CLI?

No. They share a vendor and a terminal, and little else.

OpenAI CLICodex CLI
What it is"The official command-line tool for the OpenAI REST API""A coding agent from OpenAI that runs locally on your computer"
Commandopenaicodex
InstallPrebuilt binary, Homebrew (openai/tools/openai) or go installInstall script, npm (@openai/codex), Homebrew cask
Sign-inAPI key (OPENAI_API_KEY), admin key for admin endpointsSign in with ChatGPT (recommended for paid plans) or API key
Who decides what runsYou: one command, one API requestThe agent: it reads files, edits code and runs commands
SandboxNone needed; it only calls the APISandbox modes from read-only to danger-full-access
ScriptingEvery command; --format and --transform for pipelinescodex exec for scripts and pipelines
LicenseApache 2.0Apache 2.0
GitHub stars, October 23, 2026about 1,090about 130,600

Table 1The OpenAI CLI executes requests you write; Codex CLI decides what to do and runs it in a sandbox. Source: openai/openai-cli README and OpenAI CLI docs; openai/codex README and Codex CLI and sandboxing docs.

Last verified: October 23, 2026

OpenAI draws the line the same way. The README now opens with the question "OpenAI CLI or Codex CLI?": use openai "when you want to call a specific API or put API operations in a script," and Codex CLI "when you want a coding agent to work on a project." The OpenAI CLI docs page recommends the CLI for API work "you want to inspect and rerun," such as batch extraction, file transforms and artifact generation, and Codex subagents for work that needs judgment, such as exploring code, debugging or reviewing changes. It also mentions "Codex-authored batch scripts," which suggests the two can work together: an agent writes a script that calls openai, and you rerun it without the agent.

Codex CLI brings the agent's risks with it. It runs with a sandbox (Seatbelt on macOS, bubblewrap on Linux) and approval policies, and a background server added in September, covered in our story on the Codex CLI daemon. If you want an agent's harness behind an API instead, that's OpenAI's Agents API. How Codex CLI stacks up against other coding agents is in our Claude Code vs Codex vs Cursor comparison.

Does it replace the old openai command from the Python package?

In effect, yes, but watch your PATH. OpenAI's docs say "older Python SDK versions installed a legacy openai command." If your shell still finds that binary first, the commands won't match the new CLI's. Fresh installs of the new CLI aren't affected, according to the docs. As of October 23, 2026, the openai-python README describes only a Python library and doesn't document a command-line tool.

Is the OpenAI CLI new?

Not as of October 2026. The repository's GitHub Releases page shows v1.0.0 on May 5 and v1.1.0 on May 7, 2026, and both the releases and the changelog run to v1.40.5, dated October 23, 2026. OpenAI's docs page for the CLI carries no beta label, though mutual TLS support is marked beta.

What's confirmed, reported and uncertain

  • Confirmed (repository and OpenAI docs): what the CLI is, install methods, authentication, global flags, documented commands, license and changelog dates.
  • Confirmed (Codex repository and docs): Codex CLI's description, install methods, sign-in options, sandbox modes and license.
  • Conflicting: the README asks for Go 1.26 or later and says images save to disk, while OpenAI's documentation page still says Go 1.25 and describes no native image output option.
  • Uncertain: the full list of API endpoints the CLI covers, since the README points to --help rather than listing them. No OpenAI blog post announcing the CLI was found.

Read next

Comments (0)

More on OpenAI

View all
Products · CompareChatGPT vs Perplexity (October 2026): plans, prices, search, models and which to pickChatGPT vs Perplexity in October 2026: Perplexity Pro lists $17 a month billed annually and Max $200 a month, against ChatGPT Plus at $20 and Pro from $100. How search and citations, deep research, agents, models, file limits, ads and privacy compare, from both companies' own pages.·8 min read
Models · CompareGPT-6 Astra vs GPT-6.1 Sol vs GPT-6 Luna: what each OpenAI model is for, prices, limits and which to use (October 2026)GPT-6 Astra vs 6.1 Sol vs Luna, compared on OpenAI's own pages as of October 23, 2026: Astra costs $10/$50 per million tokens, GPT-6.1 Sol $2/$10 and Luna $0.10/$0.50, all with a 1.05M-token context, but they sit in different parts of ChatGPT.·8 min read
Models · BenchmarksBest AI image generators (October 2026), according to LMArena and Artificial Analysis: OpenAI's GPT-Image-2.5 ranks first on bothLooking for the best AI for image generation? On October 23, 2026, OpenAI's GPT-Image-2.5 Sunburst ranks first on LMArena's text-to-image leaderboard and on Artificial Analysis's text-to-image and editing boards. Here's who follows, what each costs and where you can use it.·8 min read
Research · AnalysisOpenAI agent monitor red team: how METR and Redwood researchers found agents could slip past itAn OpenAI agent monitor red team exercise by one METR and one Redwood Research employee, published October 22, 2026, describes how OpenAI's internal agents could have avoided or broken misalignment monitoring as it stood on July 21. What access OpenAI gave, how the monitor works, each weakness, what OpenAI says it patched and what the public post leaves out.·8 min read
The Week in AI · every Friday

New guides and explainers, every Friday.

The week’s biggest stories in AI and tech, what they mean, and what to read next.

Free. One email a week. Unsubscribe in one click.