OpenAI ships an official CLI for calling its API from the shell

OpenAI's open-source openai CLI turns API calls like image generation, file uploads and batch jobs into shell commands for scripts.

OpenAI has published an official command line for its REST API that lets you generate images, upload files, submit batches and inspect results "without writing an application," according to the repo. If you keep small Python or Node scripts around just to push a JSONL batch or pull a file, this replaces that glue with shell one-liners you can drop into cron jobs or CI.

Commands follow the API's resources (openai <resource> [subresource...] <command> [flags...]). A batch run, per the README:

openai files upload requests.jsonl --purpose batch
openai batches create --input-file-id file-example \
  --endpoint /v1/responses --completion-window 24h
openai batches wait batch_example --output-dir ./results  # downloads results

Install via brew install openai/tools/openai, prebuilt binaries, or go install with Go 1.26 or later. Standard calls use OPENAI_API_KEY; admin endpoints such as organization usage need a separate OPENAI_ADMIN_KEY. Help works without a key or network.

One scripting gotcha, flagged by both the README and explainx.ai's guide: output is readable text by default, even in pipes, so pass --format json or jsonl when parsing. The guide also notes --debug logs request bodies and that OPENAI_UNTRUSTED_STDIN=1 blocks @file reads from piped JSON or YAML.

This is not Codex CLI. The README says to use codex for a coding agent and openai for specific API calls; a Note post adds that API usage is billed separately from a ChatGPT plan. That post also counts eight releases in 20 days, so pin a version before relying on it. Pull requests are limited to collaborators; issues are open.

Sources