openai/openai-cli

Official CLI for the OpenAI API

What it solves

It provides a standardized, official command-line interface (CLI) for interacting with the OpenAI REST API, eliminating the need to write custom scripts or use raw HTTP requests for common API tasks.

How it works

The tool uses a resource-based command structure (openai [resource] <command> [flags]) to map CLI commands to API endpoints. It supports various authentication methods, including standard API keys, admin keys, and mutual TLS (mTLS) for secure communication. It handles file uploads using a specific @ syntax and provides flexible output formatting options (such as JSON, YAML, and readable text) to allow for both human reading and machine parsing.

Who it’s for

Developers and system administrators who want to integrate OpenAI's models and admin tools into their terminal workflows, shell scripts, or automation pipelines.

Highlights

  • Resource-based commands: Organized by API resource for intuitive navigation.
  • Flexible output: Supports multiple formats including json, jsonl, yaml, and text for easy piping into other tools.
  • Secure authentication: Supports API keys, admin keys, and mutual TLS (mTLS) in beta.
  • File handling: Simplified file passing via @ syntax with automatic filetype sniffing for text vs binary data.
  • Data transformation: Built-in support for GJSON syntax to transform and extract specific data from API responses.
  • Integrated image saving: Automatically saves generated images to a local directory and provides a preview feature.

Related

  • Project
  • Project
  • Project
  • Project
  • Project