A developer-friendly ChatGPT terminal UI built with Textual. Chat with OpenAI models directly from your terminal — with conversation history, model switching, and a clean keyboard-driven interface.
Main chat view — streaming responses with sidebar conversation history and relative timestamps
Multiline input — write multi-line messages with the TextArea input (Ctrl+Enter to send)
Conversation history — browse and resume past conversations from the sidebar
Sidebar overview — full layout with recents panel and token usage in the status bar
- Streaming responses — see tokens as they arrive, just like the web UI
- Multiline input — write multi-line messages;
Ctrl+Enterto send - Stop generation — cancel a response mid-stream with
Ctrl+X - System prompt — set a custom persona per conversation with
Ctrl+P - Token usage — prompt and completion token count shown after every response
- Persistent conversations — all chats saved locally as JSON files
- Model switching — switch between GPT models without leaving the app
- Sidebar with timestamps — browse and resume previous conversations with relative times
- CLI argument —
chatgpt "your question"starts a chat immediately - First-run onboarding — prompts for your API key on first launch
- Keyboard-first — no mouse required
- Python 3.11+
- An OpenAI API key
pip install chatgpt-cligit clone https://github.com/abhisheksharma/chatgpt-cli.git
cd chatgpt-cli
pip install .chatgptOr start with an initial prompt directly:
chatgpt "explain async/await in Python"On first launch, you'll be prompted to enter your OpenAI API key. It's saved to your local config and never leaves your machine.
Alternatively, set the environment variable before running:
export OPENAI_API_KEY=sk-...
chatgptOr create a .env file in your working directory:
OPENAI_API_KEY=sk-...
| Key | Action |
|---|---|
Ctrl+Enter |
Send message |
Ctrl+N |
New conversation |
Ctrl+M |
Change model |
Ctrl+P |
Set system prompt |
Ctrl+X |
Stop generation |
Ctrl+K |
Focus message input |
Ctrl+D |
Delete conversation |
Ctrl+Q |
Quit |
gpt-4o(default)gpt-4o-minigpt-4-turbogpt-3.5-turbo
Config is stored at ~/.config/chatgpt-cli/config.json (macOS/Linux) and contains:
{
"api_key": "sk-...",
"model": "gpt-4o"
}The OPENAI_API_KEY environment variable always takes precedence over the config file.
Conversations are stored as individual JSON files at:
~/.local/share/chatgpt-cli/conversations/
Each file is human-readable and named by a UUID. You can back them up, move them, or delete them manually.
chatgpt_cli/
├── app.py # Main Textual app, UI layout, widgets, and modals
├── api.py # OpenAI streaming API integration
├── config.py # API key and model preference persistence
└── storage.py # Conversation read/write/delete
MIT