A simple, elegant command-line interface for chatting with OpenAI's GPT models.
Perfect for developers who want quick access to GPT without leaving the terminal.
- One-off questions for quick answers
- Interactive chat mode with conversation history
- Beautiful colored output with Rich
- Fast and lightweight
- Typer – CLI framework
- Rich – Terminal formatting and spinners
- python-dotenv – Environment variable management
- Python 3.8 or higher
- Poetry for dependency management
- An OpenAI API key (get one here)
- Clone the repository:
git clone https://github.com/yourusername/gpt-cli.git
cd gpt-cli- Create a
.envfile in the project root:
OPENAI_API_KEY=your_openai_api_key_here- Install dependencies:
poetry installpoetry run python main.py question "Explain what is REST API"poetry run python main.py chatType your messages and press Enter. Type exit to quit.
One-off question:
$ python main.py question "What is Docker?"
Docker is a platform that allows developers to package applications
into containers—lightweight, portable units that include everything
needed to run the software...Interactive chat:
$ python main.py chat
You can message ChatGPT now. When you finish, type "exit".
What's the capital of France?
The capital of France is Paris.
What's it famous for?
Paris is famous for the Eiffel Tower, the Louvre Museum, its art,
culture, fashion, and cuisine. It's known as "The City of Light"...
exit"Module not found" error:
Make sure you're running commands with poetry run or activate the Poetry shell first:
poetry shell
python main.py question "Your question"API key error:
Verify your .env file is in the project root and contains a valid OpenAI API key.