CLI for developers who want AI automation in their terminal.
Features: Thread history, MCP integration, prompt files, image/audio I/O, streaming, web search, pipe context.
🤖 Autonomous Agent Mode - Agents that plan and execute multi-step tasks with ReAct and Plan/Execute strategies. Combines shell commands, file ops, and LLM reasoning with budget and policy controls for safe automation.
ChatGPT CLI is a powerful, multi-provider command-line interface for working with modern LLMs. It supports OpenAI, Azure, Perplexity, LLaMA, and more, and includes streaming, interactive chat, prompt files, image/audio I/O, MCP tool calls, and an agent mode for multi-step tasks with safety and budget controls.
Seamless conversations with individualized context for each thread. Each unique thread has its own history, ensuring relevant and coherent responses across different chat instances.
# Work on different projects
chatgpt --thread backend "explain this API"
chatgpt --thread frontend "review this React component"
History automatically trims to stay within token limits while preserving context. Window size adjustable through the context-window setting.
Pipe context from files, stdin, or any program:
# Analyze log files
tail -f app.log | chatgpt "summarize errors"
# Review code
cat main.go | chatgpt "suggest improvements"
# Process images
pngpaste - | chatgpt "What is this photo?"
Run multi-step tasks that can think, act, and observe using tools like shell, file operations, and LLM reasoning. Supports both iterative ReAct loops and Plan/Execute workflows, with built-in budget limits and policy enforcement for safe-by-default automation.
ReAct Mode - Iterative "think → act → observe" loop:
chatgpt "why is my test failing?" --agent
Plan/Execute Mode - Generates a plan first, then executes step-by-step:
chatgpt "what is the weather like in brooklyn" --agent --agent-mode plan
Agent file access can be restricted to a working directory:
chatgpt "what files are in the /tmp directory" \
--agent \
--agent-work-dir .
Agent execution is governed by:
Detailed execution logs automatically written to $OPENAI_CACHE_HOME/agent/. Each run gets its own timestamped log directory with:
Allow compatible models (e.g. gpt-5+) to fetch live web data during queries:
chatgpt "latest AI developments" --web --web-context-size high
Call external MCP tools via HTTP(S) or STDIO, inject results into conversation context, and continue seamlessly.
HTTP example:
chatgpt \
--mcp "https://mcp.apify.com/?tools=epctex/weather-scraper" \
--mcp-tool "epctex-slash-weather-scraper" \
--mcp-header "Authorization: Bearer $APIFY_API_KEY" \
--mcp-param locations='["Brooklyn, NY"]' \
"what should I wear today"
STDIO example:
chatgpt \
--mcp "stdio:python test/mcp/stdio/mcp_stdio_server.py" \
--mcp-tool echo \
--mcp-param 'payload={"foo":"bar"}' \
"What did the MCP server receive?"
MCP sessions are automatically initialized and managed.
--image--draw and --output--draw, --image, and --output (e.g., "add sunglasses to the cat")chatgpt --image photo.jpg "describe this image"
chatgpt --draw "sunset over brooklyn bridge" --output sunset.png
chatgpt --draw --image cat.jpg --output cat-cool.jpg "add sunglasses"
--audio (MP3/WAV)--transcribe (supports MP3, MP4, MPEG, MPGA, M4A, WAV, WEBM)--speak and --outputchatgpt --audio meeting.mp3 "summarize this meeting"
chatgpt --transcribe interview.wav
chatgpt --speak "convert this to audio" --output speech.mp3
Provide rich context from files with --prompt:
git diff | chatgpt --prompt prompts/write_pull-request.md
Check out the awesome prompts repository for ready-to-use examples.
Access available models with -l or --list-models:
chatgpt --list-models
config.yaml, environment variables, command-line flags--target flag--set- flags--configbrew tap kardolus/chatgpt-cli && brew install chatgpt-cli
Pre-built binaries available for:
Download from GitHub Releases
export OPENAI_API_KEY="your_api_key"
mkdir -p ~/.chatgpt-cli
chatgpt "what is the capital of the Netherlands"
chatgpt --interactive
Use --target to switch between provider configurations:
~/.chatgpt-cli/
├── config.yaml # Default (OpenAI)
├── config.azure.yaml # Azure setup
├── config.perplexity.yaml # Perplexity setup
└── config.llama.yaml # LLaMA setup
chatgpt --target azure "hello"
name: azure
api_key: <key>
url: https://<resource>.openai.azure.com
completions_path: /openai/deployments/<deployment>/chat/completions?api-version=<version>
auth_header: api-key
auth_token_prefix: ""
name: perplexity
api_key: <key>
model: sonar
url: https://api.perplexity.ai
chatgpt --set-model gpt-4o
chatgpt --set-thread backend-work
chatgpt --config # View current config
Built by developers, for developers. ChatGPT CLI brings the power of modern LLMs directly to your terminal—where you already work. No context switching, no web UI, just command-line efficiency with the safety and flexibility needed for real-world automation.
No comments yet.
Sign in to be the first to comment.