Last Updated: 2026-01-07
A simple but powerful CLI chat application using Upstash Redis for persistent messaging.
- ✅ Single Chat Room - One unified chat space for all users
- ✅ Custom Usernames - Choose any username when joining
- ✅ Message History - View last 20 messages with timestamps
- ✅ Interactive Mode - Easy-to-use command interface
- ✅ Background Streaming - Real-time message updates while typing
- ✅ Timestamps - Each message includes exact timestamp
- ✅ Colorized Output - Beautiful terminal UI with colors
pip install -r requirements.txtThe .env file is already configured with your Upstash credentials:
UPSTASH_REDIS_REST_URL="https://glad-coyote-12496.upstash.io"
UPSTASH_REDIS_REST_TOKEN="ATDQAAIncDJkMGMyZGE3MTViYjI0NWMyYmU2YzA0NWY2OWViNDM0YXAyMTI0OTY"
python chat.pyTo use the AI chatbot features:
- Obtain an API key from Google AI Studio.
- Either add it to your local
.envfile:GEMINI_API_KEY="your_api_key_here" - OR use the shared key feature inside the app:
This saves the key to the shared Redis storage so everyone on the team can use it without needing their own key!
/set_gemini_key your_api_key_here
| Command | Description |
|---|---|
/history |
Display last 20 messages |
/gemini |
Enter AI Chat Mode 🤖 |
/set_gemini_key <key> |
Share an API key with the group 🔑 |
@user /silent <msg> |
Send a private message 🤫 |
/help |
Show help menu |
/quit |
Exit the application |
| Any text | Send a message |
Each message stores:
- Username - Who sent it
- Message - The actual message content
- Timestamp - When it was sent (YYYY-MM-DD HH:MM:SS)
- Recipients - For private messages
- Is Silent - Flag for private messages
- Messages are stored in Upstash Redis using a list (LPUSH)
- Background thread checks for new messages every 1 second
- New messages appear in real-time while you're typing
- Gemini Integration:
- The app first checks your local
.envfor a key. - If missing (or is a placeholder), it fetches the shared key from Redis (
chat:config:gemini_key). - This allows seamless AI usage for all team members.
- The app first checks your local
- Python 3.x
- Upstash Redis (REST API)
- Google Generative AI (Gemini)
- Requests - HTTP library for Redis communication
- Threading - Background message streaming
- Colorama - Terminal colors
- python-dotenv - Environment variable management
============================================================
Welcome to Redis Chat CLI!
============================================================
Enter your username: Alice
--- New message(s) received ---
[2026-01-02 10:30:45] Bob: Hey everyone!
[2026-01-02 10:31:12] Charlie: Hello!
>>> /gemini
============================================================
Entered Gemini AI CLI Mode
Type your prompt or /exit to return to chat
============================================================
Gemini > Write a poem about coding
Thinking...
In realms of logic, lines involved,
A digital tapestry evolved...
Gemini > /exit
Exiting Gemini Mode...
>>> /set_gemini_key AIzaSy...
✓ Gemini API Key saved to shared storage! Friends can now use it.
>>> Hi there!
✓ Message sent
Enjoy chatting! 🚀