kardolus/chatgpt-cli

ChatGPT CLI is a powerful, multi-provider command-line interface for working with modern LLMs. It supports OpenAI, Azure, Perplexity, LLaMA, and more, with features like streaming, interactive chat, prompt files, image/audio I/O, MCP tool calls, and an experimental agent mode for safe, multi-step automation.

ChatGPT CLI – a terminal front‑end for modern LLMs

What it is – A single‑binary command‑line tool that lets you talk to a variety of large‑language‑model providers (OpenAI, Azure, Perplexity, LLaMA, etc.) directly from the shell. It supports ordinary query mode, a streaming “live‑typing” mode, an interactive REPL, and an experimental agent mode that can run multi‑step tool‑using workflows.

Key capabilities

  • Provider‑agnostic – configure any supported LLM via a config.yaml or environment variables.
  • Streaming & query modes – get token‑by‑token output or a single response.
  • Threaded context – each thread keeps its own chat history with a sliding‑window that trims automatically to stay under token limits.
  • Prompt files--prompt <file> injects a full‑text prompt (e.g. a markdown guide) before your query.
  • Multimedia I/O – upload images (--image), generate images (--draw), upload audio (--audio), transcribe (--transcribe), and synthesize speech (--speak).
  • MCP (Model Context Protocol) – call external tools over HTTP or stdio, have the CLI manage sessions, and inject the tool’s result into the conversation as context.
  • Agent mode – a ReAct or Plan/Execute loop that can run shell commands, read/write files, and respect configurable budget (steps, tokens, wall‑time) and policy (allowed tools, denied commands, work‑dir sandbox).
  • Web search – optional live web fetch for models that support it.
  • Auto‑completion – generate Bash/Zsh/Fish completions via chatgpt completion.

Installation

  • Homebrew (macOS): brew tap kardolus/chatgpt-cli && brew install chatgpt-cli (trust the tap once).
  • Pre‑built binariescurl -L …/chatgpt-<os‑arch> then chmod +x and move to a directory on your PATH (examples for Apple Silicon, Intel macOS, Linux amd64/arm64/386, FreeBSD, Windows are in the README).

Getting started

  1. Export your OpenAI key: export OPENAI_API_KEY=sk‑… (or configure another provider).
  2. Create the history directory: mkdir -p ~/.chatgpt-cli.
  3. Simple query: chatgpt "what is the capital of the Netherlands".
  4. Interactive REPL: chatgpt --interactive.
  5. Use a prompt file: chatgpt --prompt my‑prompt.md "Summarize this code".
  6. Run an agent task: chatgpt "why is my test failing?" --agent (or add --agent-mode plan).

Configuration

  • Settings can be supplied via flags, environment variables (prefixed with the config name), a config.yaml file, or fall back to built‑in defaults. The hierarchy is flag > env > file > default.
  • Provider‑specific sections (OpenAI, Azure, Perplexity, 302 AI, Atlas Cloud) let you store API keys, endpoint URLs, model defaults, etc.
  • Agent‑specific options let you set default policies, budget limits, and a sandbox work directory.
  • The --target flag lets you switch between multiple config files.

Typical use‑cases

  • Quick look‑ups without opening a browser.
  • Scripting: pipe file contents or command output into the CLI and get a model‑generated answer.
  • Automated workflows: use agent mode to let the model run a series of shell commands safely.
  • Extending with custom tools via MCP – e.g., call a weather‑scraper service and feed the result back to the model.

Where to find more


All details above are taken directly from the project's README; no additional features have been inferred.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project