Glowing terminal window sending streams of light to image, audio and file icons on dark navy

OpenAI’s Official CLI: Automate API Tasks From One Command

In short

  • OpenAI has an official, open-source command-line tool for its API (Apache 2.0), and it reached Hacker News on October 22
  • One command can call text, image, speech, file and batch endpoints, and token counting runs locally at no cost
  • Automating a manual daily usage check and a freelancer-written script is worth about €735 in the first year (my assumptions)

You do not need an app, a no-code tool or a developer to call the OpenAI API. You need one command. OpenAI published an official CLI: a small program you run in a terminal. The old way was a freelancer writing a wrapper script, or a person clicking through a dashboard every morning. The new way is a single line you can put in a cron job.

What the tool is

The `openai` CLI is the official command-line tool for the OpenAI API. It is written in Go, open source under the Apache 2.0 license, and it is not Codex CLI, the coding agent. It calls API endpoints directly, so you can use the API from a terminal or a shell script without building an application.

What it covers:

  • Responses: text, structured output, web search and file inputs
  • Images: generation and editing
  • Audio: speech generation and transcription
  • Files and batches: upload, download, submit and wait on batch jobs
  • Webhook testing and local token counting
  • Admin endpoints: projects, service accounts and usage, with a separate admin key

Output can be plain text, JSON, JSONL or YAML, which makes it easy to pass into other scripts.

What does it cost? The tool itself is free. API usage is billed at your normal OpenAI rates, and the CLI pages do not list prices, so check OpenAI’s pricing page before you plan a big job.

Setup in 10 minutes

I did not run every command below against a live account. The model name in the examples may not match what your account offers, so check with `openai models list` first.

  1. Install it. On macOS or Linux with Homebrew:
brew install openai/tools/openai

Or download a prebuilt binary for macOS, Linux or Windows from GitHub Releases. Or, with a recent Go version (the README asks for 1.26 or later):

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

If you installed the older Python SDK before, its legacy `openai` command may still win in your shell. Check which one runs.

  1. Set your key.
export OPENAI_API_KEY="sk-..."
openai help setup
  1. Make your first call.
openai responses create --model gpt-5.5 --input "Say this is a test"
  1. Read a prompt from a file. The `@` prefix loads the file’s content.
openai responses create --model gpt-5.5 --input @prompt.txt
  1. Get machine-readable output. Add `–format json` or `–format jsonl` when another script will read the result.
  2. Count tokens before a big job. This runs locally, with no network request and no API cost.
openai tokens count --model gpt-5.5 "your text here"
  1. Generate an image. The CLI decodes the result and saves a PNG for you.
openai images generate --prompt "A tiny orange robot"
  1. Pull a daily usage report. This needs an admin key. The line below is an illustration: the timestamps are examples, and a real job would calculate yesterday’s range in a small script.
0 6 * * * OPENAI_ADMIN_KEY="$ADMIN_KEY" openai admin organization usage completions --start-time 1735689600 --end-time 1735776000 --bucket-width 1d --format json >> /var/log/openai-usage.jsonl

Keep the admin key only in the job that needs it, not on every laptop.

Real use cases

  • Batch jobs. Upload a JSONL file, then create a batch with a 24-hour completion window. Good for bulk descriptions, translations and tagging.
  • Scheduled reports. The usage pull above, written to a log file you can read or chart.
  • Quick tests. Try a prompt in one line before you build the same step into Make or n8n.
  • Simple automations. Anything a shell script can trigger can now call the API in one line.

How I would use it at GiantParts: draft product descriptions from a CSV in a batch, and count the tokens first so the bill has no surprises. That is a plan, not a result.

Do the math: these are my assumptions. A freelancer writes a small wrapper script: 3 hours at €25 is €75, once. Someone checks API usage by hand for 10 minutes a day, 22 working days a month: 220 minutes, about 3.7 hours, at €15 an hour is about €55 a month, or €660 a year. With the CLI and a cron job, the manual check disappears. First year: €75 plus €660 is €735 saved. The tool costs €0, and the API usage is money you would spend anyway.

Limits and weak spots

  • Missing features. Per-command cost reporting, project-level config files and workflow automation are not there yet.
  • Go version. The `go install` route needs a recent Go.
  • Network setup. Mutual TLS is in beta and needs enrollment. HTTPS proxies are rejected. A custom base URL must use HTTPS unless it points to localhost.
  • Untrusted input. If you pipe in text you do not control, turn on the untrusted stdin mode (`OPENAI_UNTRUSTED_STDIN=1`) so local file reads from piped data are blocked.
  • Terminal skills. This is for people who are comfortable in a terminal. If you are not, start with Make or n8n.

Alternatives

  • curl: works anywhere, but you type far more.
  • The official Python and JavaScript SDKs: the right choice when you are building a real application.
  • Make or n8n: no-code workflows when you would rather click than type.

What it means

My read: a stable command-line tool is a clean way for scripts and AI agents to call the API, because agents can already run shell commands. OpenAI is making the API easy to use from anywhere. Anthropic and Google will have to answer with the same thing, or lose the people who live in terminals.

Ivan’s Take

I like small tools that remove a daily chore. This one removes the manual usage check and gives me a scripted way to run batches. It is free, so the test costs nothing but an hour. I would install it today, run the token counter and one batch, and only then decide whether it earns a place in my stack.

Source: OpenAI

II
About the author
Ivan Ivanov
Founder ofAI Rush XGiantPartsSupreme CommerceHawkValue

If it doesn’t save you time or money, you won’t see it here

  • Facts, not hypeEvery price and number is checked against the official source
  • Always the real priceYou see what it costs before you click
  • I say when it’s weakEven when it’s OpenAI or Google
All articles by Ivan →

Similar Posts