Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatgpt-cli

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.

Screenshots

Main chat view — streaming responses with sidebar conversation history and relative timestamps

Main chat view

Multiline input — write multi-line messages with the TextArea input (Ctrl+Enter to send)

Multiline input

Conversation history — browse and resume past conversations from the sidebar

Conversation history

Sidebar overview — full layout with recents panel and token usage in the status bar

Sidebar overview

Features

  • Streaming responses — see tokens as they arrive, just like the web UI
  • Multiline input — write multi-line messages; Ctrl+Enter to 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 argumentchatgpt "your question" starts a chat immediately
  • First-run onboarding — prompts for your API key on first launch
  • Keyboard-first — no mouse required

Requirements

Installation

From PyPI

pip install chatgpt-cli

From source

git clone https://github.com/abhisheksharma/chatgpt-cli.git
cd chatgpt-cli
pip install .

Usage

chatgpt

Or 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-...
chatgpt

Or create a .env file in your working directory:

OPENAI_API_KEY=sk-...

Keyboard Shortcuts

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

Supported Models

  • gpt-4o (default)
  • gpt-4o-mini
  • gpt-4-turbo
  • gpt-3.5-turbo

Configuration

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.

Conversation Storage

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.

Project Structure

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

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages