explainx.ai0k
TrendingAI News TodayPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

follow on google

Add explainx.ai as a preferred source

corporate training

support@explainx.ai

get started

Find your pathTake Free Evaluation

community

Join the community

learn

mind: share how you thinkpathways — start freeworkshopsbootcampscoursescompare Explainxcertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsmdx readeragentsllmsdesignsdictionarypeopleagi trackerfelony benchranks

company

aboutvisionmissionteaminstructorsteach on explainxpartnershipscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource libraryfor LLMsexplainx.ai kids

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportcontactprivacytermsdata rightshow we create contentsubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

explainx.ai

On this page

  • TL;DR: OpenAI CLI at a glance
  • How to install and authenticate
  • The commands you will use first
  • Output, errors and scripting
  • Security features worth knowing
  • What developers on Hacker News said
  • Practical uses for a team
  • What people are asking
  • Where it fits against other tools
  • Limits and open questions
  • Related reading
← Back to blog

explainx / blog

OpenAI CLI: The Official Command Line for the OpenAI API, and How to Use It

OpenAI, Developer Tools, CLI, Guides, OpenAI API

Part of OpenAI and ChatGPT

OpenAI released an official open-source CLI for its REST API. Install with Homebrew or Go, run responses, images and files, and see the security flags.

Oct 22, 2026·9 min read·Yash Thakker
add explainx.ai
go deep
OpenAI CLI: The Official Command Line for the OpenAI API, and How to Use It

OpenAI now has an official command line for its API. The repository openai/openai-cli describes itself as "the official CLI for the OpenAI REST API," is written in Go, is licensed Apache-2.0, and had about 777 stars and 559 commits when we looked on October 22, 2026. It surfaced on Hacker News the same morning, where the thread had a few dozen points and a small discussion.

This guide covers what the tool does, how to install and authenticate, the commands most developers will use first, and the details in the README that matter for security and scripting. It is a reference built from the README and docs, not a claim that we benchmarked every endpoint. For comparison with other vendor CLIs, see our references for Claude Code commands and Gemini CLI slash commands.

TL;DR: OpenAI CLI at a glance

table · 2 cols
QuestionAnswer
What is it?A Go command line wrapping the OpenAI REST API, including admin endpoints
LicenseApache-2.0
Installbrew install openai/tools/openai, or go install (Go 1.26 or later)
AuthOPENAI_API_KEY; OPENAI_ADMIN_KEY for admin endpoints
Command shapeopenai resource subresource command flags
OutputReadable text by default, even in pipes; json, jsonl, yaml, raw via --format
UpdatesNotice only, once a week at most; disable with OPENAI_CLI_NO_UPDATE_CHECK=1
ContributionsPull requests limited to repository collaborators; issues welcome
Weekly digest3.6k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.

How to install and authenticate

On macOS or Linux with Homebrew:

bash
brew install openai/tools/openai

With Go 1.26 or later:

bash
go install 'github.com/openai/openai-cli/cmd/openai@latest'

The binary lands in your Go bin directory, by default the home directory's go/bin folder, so add it to your PATH if the command is not found. Then set a key:

bash
export OPENAI_API_KEY="sk-..."
openai help setup

The help setup page explains how to enter the key safely, which matters because keys typed into a shell can end up in history. For admin endpoints you need a separate admin key in OPENAI_ADMIN_KEY. Other environment variables the README lists are OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_WEBHOOK_SECRET, OPENAI_CUSTOM_HEADERS and the two mutual TLS file variables.

The commands you will use first

The structure is resource-based. A first call to the Responses API looks like this, straight from the README:

bash
openai responses create --input "Say this is a test" --model gpt-5.5

Admin reporting uses the admin key:

bash
openai admin organization usage completions --start-time 1735689600 --end-time 1735776000 --bucket-width 1d

Browse everything with openai, openai --help, or openai admin --help. Help works without an API key or network connection, and openai help COMMAND shows the same page as --help.

Files

Upload with an explicit purpose, inspect metadata, then download:

bash
openai files upload "upload space.txt" --purpose user_data
openai files get file-example
openai files download file-example --output "downloaded copy.txt"

Upload takes a plain path with no added at-sign, which avoids the accidental-file-read behavior described below.

Images

openai images generate --prompt "A tiny orange robot" saves results to a gpt-images folder inside Downloads and prints their paths, even in pipes. According to the README, when you do not set a model the CLI uses gpt-image-2.5-sunburst; --model picks another ID, --name sets a filename, and --output-dir chooses an existing directory. Existing files are kept. images edit also saves new results while preserving sources, and images create-variation is retired, so use images edit with a GPT Image model and a prompt instead. openai images preview redisplays a saved image without an API request.

The first eligible interactive run quietly saves image-picker Tab shortcuts for future Bash, zsh and fish sessions, with an opt-out described in the docs. That is worth knowing if you dislike tools editing shell setup.

Output, errors and scripting

By default, successful JSON responses print as readable text, including in pipes. Scripts that parse API data should pass --format json or --format jsonl. The --transform flag extracts data with GJSON syntax. Errors print actionable summaries to stderr; --format-error json returns the original API error details, and --transform-error extracts fields such as the error code. Summaries omit rejected values and request URLs, though the README warns that explicit API error details can contain server-supplied sensitive data.

Two practical consequences. First, any script written assuming raw JSON by default needs --format json. Second, treat debug output carefully: --debug logs HTTP requests and bodies, and the README tells you not to share those logs if they may contain sensitive payloads.

Security features worth knowing

The README spends real space on security, which is unusual for a CLI and relevant for teams that run it in CI.

  • Untrusted stdin mode. The CLI can read local files from at-sign references inside JSON or YAML, such as an image path in a request body. If you pipe in data from an untrusted source, set OPENAI_UNTRUSTED_STDIN=1 so those references are treated as literal text and cannot read local files. File-upload parameters then have to be passed as explicit flags.
  • Custom headers from the environment. Use OPENAI_CUSTOM_HEADERS for credential-bearing headers so secrets stay out of command arguments and shell history. Supplied header values are hidden in help and redacted in debug logs.
  • Mutual TLS (beta). To authenticate with a client certificate, provide the certificate and private key as separate PEM files through OPENAI_MTLS_CLIENT_CERT_FILE and OPENAI_MTLS_CLIENT_KEY_FILE, and set the base URL to the mTLS endpoint yourself, since the CLI does not select it automatically. HTTPS proxies are rejected to avoid presenting the client certificate during the proxy handshake. You must opt in to OpenAI's Mutual TLS Beta Program first.
  • HTTPS enforcement. A custom --base-url must use HTTPS except for localhost or loopback addresses.

If you run agents that call this tool, keep the same discipline as for other secrets: our guide to the OpenAI secure MCP tunnel covers one way to keep internal systems off the public internet, and the LiteLLM compromise post shows what happens when API keys leak from tooling.

What developers on Hacker News said

The discussion is small but touches the right questions. One commenter, hahahacorn, guessed the strategy is to train models to use first-party tools efficiently so they default to services such as managed agents, and was surprised it had not shipped sooner. Another, mi_lk, asked when to use it over Codex and whether other tools or agents are meant to call it. A third, throw20261022, warned about building deeply on OpenAI tooling, claiming OpenAI deprecates many products within two years. These are individual opinions, not verified facts, and the repository's own history is the better evidence of maintenance: 559 commits and a changelog in the repo.

On the Codex question, the README does not describe the CLI as an agent. It is a thin wrapper for calling API endpoints, so the honest answer is that they do different jobs. Our Codex usage and sign-in post covers the agent side.

Practical uses for a team

A command line over the whole API earns its place in a few repeatable situations, even if you already use an SDK.

Cost and usage checks. The admin usage commands take a start time, end time and bucket width, so a scheduled job can pull yesterday's completions usage into a spreadsheet or alert without writing client code. Because admin endpoints need a separate admin key, keep that key out of developer laptops and limit it to the job that needs it.

Debugging production calls. When an application gets a surprising answer, reproducing the exact request from a terminal removes your application code from the equation. The --debug flag shows the HTTP exchange, and --format-error json returns the raw error envelope, which helps when a vendor error message is vague.

One-off file and image work. Uploading a file for later use, or generating a quick image with the default preset, is faster than opening a notebook. The behavior of saving results to a predictable folder and keeping existing files makes it safe to run repeatedly.

CI smoke tests. The tool skips update checks in CI and when streams are redirected, so it will not add surprise network calls to pipelines. A short models list check can confirm that a key and project are valid before a deploy.

What people are asking

Is this the same as the old Python command that shipped with the SDK? The README does not say, so do not assume compatibility. This tool is a separate Go project with its own command structure.

Will it work with other providers? It targets the OpenAI REST API, though a custom --base-url is supported, subject to the HTTPS rule. Compatibility with third-party servers is not documented.

Can an AI agent drive it? Nothing prevents that, and the untrusted-stdin protection suggests the authors expect piped data from other programs. Give agents a restricted key, because a CLI that can read files and call admin endpoints is powerful in the wrong hands.

Where it fits against other tools

table · 2 cols
NeedBetter fit
Call one endpoint from a shell script or cron jobOpenAI CLI
Debug a request or inspect usage and costsOpenAI CLI, including admin usage reports
Embed model calls in an appAn official SDK
Autonomous coding in a repoCodex or another coding agent; see our Claudex setup guide
Route across providersA gateway such as Prime Inference

Limits and open questions

The repository forbids pull requests from non-collaborators, so outside contributors can file issues only. The generated-code layout (a generated folder, a release-please setup and a Stainless-style stats file) suggests much of the surface is produced from the API spec, which keeps it current but also means the command list will track API changes closely. We have not tested every command against live endpoints, and model IDs in examples, such as gpt-5.5 and the default image model, may differ from what your account can access. Check your own model list with openai models list.

Related reading

  • Claude Code commands: complete reference
  • Gemini CLI slash commands reference
  • Codex usage limits and sign-in with ChatGPT
  • OpenAI secure MCP tunnel guide
  • Prime Inference launch
  • LiteLLM 1.107.0 compromise: what to do
  • What is MCP? Complete guide
  • Google's Gemini API CLI, the Gemini counterpart for shell agents

Details are from the openai/openai-cli README on October 22, 2026 and may change with new releases. See OpenAI's API documentation for current endpoints.

Spotted something out of date? Let us know.
Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

View Yash Thakker in People in AI →

Related posts

Oct 22, 2026

claude-howto: The 42K-Star Claude Code Guide, and How to Use It Well

luongnv89/claude-howto gained 428 stars in a day and sits near 42,600 total. It is a ten-module, example-driven guide to Claude Code with copy-paste templates for commands, memory, skills, subagents, MCP, hooks and plugins. Here is what it contains, how to use it safely, and what to check before you trust it.

Oct 22, 2026

OpenAI Usage Policies Change November 20: Routers and AI Gateways Need Approval

OpenAI says partners that host or resell its models must keep safeguards at least as strong as its own, and its updated Usage Policies, effective November 20, 2026, require model routers and AI gateways to get approval first. We explain what changed, who is affected, and what to check.

Oct 20, 2026

ChatGPT Locked Chats: PIN or Face ID, Separate Memory, and What It Does Not Protect

OpenAI has begun rolling out Locked Chats in ChatGPT, a screen-privacy feature that moves sensitive conversations behind a PIN or biometric check with their own memory. It is not encryption and does not change retention or training settings. Here is how it works and when to use it.