ChatGPT CLI
A Go command-line client for working with OpenAI, Azure, Perplexity and LLaMA language models right from the terminal
- 965 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- The --agent mode runs shell commands and file operations at the model's discretion
- The OpenAI or other provider key comes from environment variables, and query text with added context goes to the provider
- Conversation history is stored on disk as plain text
Install
Manual install
brew tap kardolus/chatgpt-cli && brew trust kardolus/chatgpt-cli && brew install chatgpt-cliFor macOS. Since Homebrew 6.0 the brew trust step is required.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The --agent mode runs shell commands and file operations at the model's discretion
- The OpenAI or other provider key comes from environment variables, and query text with added context goes to the provider
- Conversation history is stored on disk as plain text
This is third-party code. Review the repository files before installing.
What it does
ChatGPT CLI is a Go program with the chatgpt command. You ask a question right in the terminal, get a streamed answer, switch to an interactive chat or pipe another command's output into the query. For example, `git diff | chatgpt --prompt write_pull-request.md` writes a change description from your instruction file. Each conversation lives in its own thread with its own history. Settings and the --target flag switch the provider: OpenAI, Azure, Perplexity or LLaMA. The program handles images and audio, transcribes recordings and reads text aloud, and gives web search to models that support it. For agent scenarios there are two flags. With --mcp the program calls a tool on a remote MCP server and puts its reply into the conversation before querying the model. With --agent the model plans and runs steps itself in a ReAct or Plan/Execute scheme.
Who it is for. For developers and administrators who work with models from the terminal, build pipes in scripts and want to switch providers with one flag.
Good fit when
- You want a quick question to a model from the terminal with no browser and a streamed answer
- You want to pipe command output into a model, for example git diff for a pull request description or a log for error analysis
- You switch between OpenAI, Azure, Perplexity and local LLaMA
- You need to call a tool on a remote MCP server and add its result to the conversation in one request
- You want an agent for small terminal tasks with limits on steps and tokens
Not a fit when
- You need a full coding agent that edits a repository and keeps sessions: the --agent mode is experimental
- You have no access to any cloud provider and no server of your own for LLaMA
- You need MCP over stdio or a persistent connection: the documentation describes an HTTP tool call
- You want to attach a ready MCP server to an agent: ChatGPT CLI calls a tool once and does not register a server for an agent
Example request
Send the git diff output to chatgpt with the write_pull-request.md instruction file and show the finished pull request descriptionLimitations
- OpenAI needs a key in the OPENAI_API_KEY variable. The OpenAI API is unavailable from Russia; in that case use another provider or local LLaMA.
- Image generation, audio and speech work only with OpenAI models that support them.
- The --target value is not saved between runs, so it is passed on every call.
- Azure needs its own key and resource address in the settings file.
- OpenAI's json_object mode requires the prompt to mention JSON.
How to disable. On macOS with Homebrew run brew uninstall chatgpt-cli and brew untap kardolus/chatgpt-cli. If you installed the binary, delete the chatgpt file from /usr/local/bin or the directory on your PATH. The conversation history directory can be deleted if you wish.
FAQ
How do I install ChatGPT CLI on macOS and Linux?
On macOS through Homebrew: brew tap kardolus/chatgpt-cli, brew trust kardolus/chatgpt-cli and brew install chatgpt-cli. On Linux download the ready binary for amd64 or arm64 from the releases, run chmod +x and move it to /usr/local/bin.
How do I use ChatGPT CLI with Perplexity or LLaMA instead of OpenAI?
Create a separate settings file config.perplexity.yaml or config.llama.yaml and run the program with the --target flag, for example chatgpt --target perplexity "question".
How do I call an MCP tool from ChatGPT CLI?
Give the server address with --mcp, the tool name with --mcp-tool and arguments with --mcp-param. The program sends a tools/call request over HTTP, opens a session itself, adds the tool's reply to the conversation thread and then asks the model your question.
Is it safe to turn on the --agent mode?
The mode is experimental and can run shell and file operations. Restrict it: --agent-work-dir denies reads and writes outside the folder, and a budget and policy set limits on time, steps, tokens and allowed commands. Run logs are in $OPENAI_CACHE_HOME/agent/.
Where does ChatGPT CLI keep conversation history and how do I turn it off?
If you create the ~/.chatgpt-cli directory, the program keeps history per thread, by default in ~/.chatgpt-cli/history/default.json. History holds only the conversation, and the context window slides within the token limit. Without the directory no history is saved. To clear it, delete the folder by hand.
Discussion
No questions or reviews yet.
Related
CLI toolsA desktop app with a local MCP server that lets ChatGPT work with files, commands, skills and other MCP servers
An ai-forever proxy that serves GigaChat through OpenAI, Anthropic and Gemini APIs so Claude Code, Codex and Gemini CLI can run on it
A personal AI agent for the terminal with shell, Python, web and local models, one of the earliest agent CLIs
A local proxy exposing GigaChat through OpenAI- and Anthropic-compatible APIs so it can drive Claude Code, aider and other agents
An MCP server that sends one prompt to several OpenAI, Anthropic, Gemini, Groq, DeepSeek and Ollama models at once and can draw a decision from them
Local coding agent with a terminal UI: it plans, drafts several candidates, tests them in a sandbox and repairs, so compact open models can handle code
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Repository stars | Main difference |
|---|---|---|---|
| ChatGPT CLI (this entry) | no | 965 | |
| AIChat | no | 10,533 | a Rust CLI with over 20 providers, RAG and tool calling |
| ShellGPT | no | 12,296 | the sgpt command that writes shell commands and code and calls functions |
| gpt-cli | no | 721 | a console chat with ChatGPT, Claude, Gemini and Cohere with assistants in YAML |
README in short
The documentation goes from installing through Homebrew and binaries to the first request with an API key, multi-file settings, prompts and agent mode. There are sections on uninstalling and contributor guidelines.