openai/openai-cli

Official CLI for the OpenAI API

What it solves

It provides a command-line interface (CLI) for interacting with the OpenAI REST API, allowing users to trigger API endpoints and manage resources without writing custom code or using a web browser.

How it works

The tool uses a resource-based command structure (openai [resource] <command> [flags...]) to map CLI calls to API endpoints. It supports authentication via standard API keys, admin API keys, and mutual TLS (mTLS) for secure connections. Users can pass data via flags, environment variables, or by referencing local files using a special @ syntax for automatic encoding (text or base64).

Who it’s for

Developers and system administrators who want to interact with OpenAI services directly from their terminal, automate API tasks via scripts, or manage organization-level usage and settings.

Highlights

  • Flexible Output: Supports multiple output formats including JSON, YAML, and pretty-print, with GJSON syntax for data transformation.
  • Secure Authentication: Includes support for admin keys and a beta mutual TLS (mTLS) implementation for enhanced security.
  • File Handling: Simplifies uploading files to the API by automatically sniffing file types to determine the correct encoding.
  • Customizable: Allows the use of a custom API backend URL via the --base-url flag.

Related

  • Project
  • Project
  • Project
  • Project
  • Project