HeadlinesBriefing HeadlinesBriefing.com

OpenAI Official CLI: Install and Usage Guide

Hacker News •
×

The openai-cli is the official command-line interface for the OpenAI REST API, hosted on GitHub. It can be installed with Homebrew using brew install openai/tools/openai, or built locally with Go 1.26 or later via go install github.com/openai/openai-cli/cmd/openai@latest. After installation, the binary is placed in the Go bin directory, typically $HOME/go/bin, and users may need to add it to their PATH if commands are not found.

The CLI follows a resource-based structure in the form openai <resource> [subresource...] <command> [flags...]. Standard API endpoints require an OPENAI_API_KEY environment variable, while admin endpoints require an OPENAI_ADMIN_KEY. Help is available offline through openai --help and per-command help pages, and the first interactive run saves shortcuts for Bash, zsh, and fish.

The CLI checks for newer stable releases when run interactively, showing a plain-text notice at most once every seven days. Checks use public GitHub release metadata, run at most once daily, and fail silently. The CLI never installs updates automatically, and the check can be disabled by setting OPENAI_CLI_NO_UPDATE_CHECK=1.

Users who want to run the tool from source can clone the repository and use the scripts/run script. Tab completion supports command groups, help topics, and file input paths, and shell completion should be reloaded after upgrading to enable the newest behavior.

Source: Hacker News · Summarized by HeadlinesBriefing