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 plain queries, streaming responses, interactive REPL sessions, and a set of “agent” capabilities that let the model call tools (shell, file system, web search, MCP services) to solve multi‑step tasks.
Key capabilities
- Streaming & query modes – real‑time token‑by‑token output or one‑shot ask‑and‑receive.
- Thread‑based context – each logical conversation (thread) keeps its own history with a sliding‑window token limit; history is stored under
~/.chatgpt-cli. - Prompt files –
--prompt <file>injects a reusable instruction file before your query. - Agent mode – experimental ReAct or Plan/Execute loops that let the model think, act, and observe using built‑in tools (shell commands, file ops, web search). Budgets (steps, tokens, time) and policy rules (allowed tools, work‑dir sandbox) keep execution safe.
- MCP (Model Context Protocol) integration – call external HTTP or stdio tools, have their JSON‑RPC result inserted into the conversation as
[MCP: <tool>]context. - Multimedia I/O – upload images (
--image), generate or edit images (--draw), upload audio (--audio), transcribe (--transcribe), and synthesize speech (--speak). - Model discovery –
-l/--list-modelsshows what models the current provider offers. - Layered configuration – flags > env vars >
config.yaml> defaults; per‑provider sections let you store keys for OpenAI, Azure, Perplexity, 302 AI, Atlas Cloud, etc.
Installation
- Homebrew (macOS):
brew tap kardolus/chatgpt-cli && brew trust kardolus/chatgpt-cli && brew install chatgpt-cli - Pre‑built binaries – curl the appropriate
chatgpt-<os>-<arch>from the latest GitHub release, make it executable, and place it on your$PATH(examples for Apple Silicon, Intel macOS, Linux amd64/arm64/386, FreeBSD, Windows are in the README).
Getting started
- Export your OpenAI key:
export OPENAI_API_KEY=sk‑… - Create the history folder:
mkdir -p ~/.chatgpt-cli - Try a simple query:
chatgpt "What is the capital of the Netherlands?" - Launch an interactive REPL:
chatgpt --interactive - Use a prompt file:
git diff | chatgpt --prompt ./prompts/write_pull-request.md - Run an agent:
chatgpt "Why is my test failing?" --agent
Configuration highlights
config.yamllives in~/.chatgpt-cli(or a custom directory via--config-dir).- Provider‑specific sections let you set API keys, base URLs, and model defaults.
- Agent‑specific settings (
budget,policy,work-dir) are configurable in the same file or via--set-…flags. - Autocompletion can be enabled for Bash/Zsh/Fish with the
--completionhelper.
Why you might care
- Keeps you in the terminal, avoiding context switches to a web UI.
- The agent mode gives you a lightweight “auto‑GPT” that can run scripts, edit files, or fetch live web data while respecting safety limits.
- MCP support means you can plug in any custom tool that follows the Model Context Protocol without writing code.
Links & resources
- Full docs: the README sections above.
- Prompt library: https://github.com/kardolus/prompts
- Issue tracker & contribution guide are linked in the repo.
Related
- Project
- Project
- Dispatch
- Project
- Project