Repolode
openai

openai/openai-cli

Official command-line client for the OpenAI REST API, covering resource-based commands for models, responses, files, images and admin endpoints.

Stars
767
Forks
79
Open issues
27
Last commit
4 hours ago

What is it?

openai-cli is the official command-line interface for the OpenAI REST API, written in Go. It organizes commands by resource, so you call `openai <resource> <command>` for operations such as creating responses, uploading and downloading files, and generating images. Standard endpoints authenticate with an API key, and admin endpoints use a separate admin key.

Beyond raw API calls, the CLI prints readable text output by default and offers JSON, JSONL and YAML formats for scripts. Its `--transform` flag extracts fields using GJSON syntax, and error output can be formatted or extracted separately. Image generation saves results to a local directory and prints their paths, and shell tab completion is available for Bash, zsh, fish and PowerShell.

The tool can be installed with Homebrew or `go install`, and it supports custom base URLs, extra request headers, and mutual TLS client certificates for organizations that use them.

Key features

  • 01Resource-based commands for OpenAI API endpoints, including admin endpoints with a separate key.
  • 02Readable text output by default, with JSON, JSONL and YAML formats for scripts.
  • 03GJSON-based `--transform` for extracting fields from responses and errors.
  • 04Image generation that saves results locally and prints file paths.
  • 05Shell tab completion and inline command suggestions.
  • 06Custom base URL, request headers and mutual TLS client certificate support.

Use cases

  • Calling OpenAI models or uploading files from the terminal while developing or debugging.
  • Scripting API workflows that parse JSON output in shell pipelines or CI jobs.
  • Generating images from the command line and saving them to a local folder.
  • Running admin usage queries against an organization from a terminal.

Quick start

  1. 1

    Install with Homebrew

    brew install openai/tools/openai
  2. 2

    Or install with Go (requires Go 1.26 or later)

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

    Set your API key in the environment

    export OPENAI_API_KEY="sk-..."
  4. 4

    Run a first request, for example creating a response

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

Things to know

  • Standard API commands require an OpenAI API key, which may incur usage costs.
  • Go installation requires Go 1.26 or later.

Topics

FAQ

What is openai-cli?
Official command-line client for the OpenAI REST API, covering resource-based commands for models, responses, files, images and admin endpoints. openai-cli is the official command-line interface for the OpenAI REST API, written in Go. It organizes commands by resource, so you call `openai <resource> <command>` for operations such as creating responses, uploading and downloading files, and generating images. Standard endpoints authenticate with an API key, and admin endpoints use a separate admin key.
Is openai-cli free to use? What license does it have?
openai-cli is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is openai-cli still maintained?
Actively maintained. The last commit to openai-cli was on Oct 22, 2026.
What can I use openai-cli for?
Calling OpenAI models or uploading files from the terminal while developing or debugging. Scripting API workflows that parse JSON output in shell pipelines or CI jobs. Generating images from the command line and saving them to a local folder. Running admin usage queries against an organization from a terminal.
How do I install openai-cli?
Install with Homebrew: brew install openai/tools/openai Or install with Go (requires Go 1.26 or later): go install 'github.com/openai/openai-cli/cmd/openai@latest' Set your API key in the environment: export OPENAI_API_KEY="sk-..." Run a first request, for example creating a response: openai responses create --input "Say this is a test" --model gpt-5.5
Where can I get openai-cli?
The source code and installation instructions are on GitHub: https://github.com/openai/openai-cli

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects