A powerful, modern terminal interface for OpenAI's API featuring a full Text User Interface (TUI) built with rcurses. Version 2.1 adds chat scrolling, enhanced UX, and improved conversation management - all from your terminal.
New features: Chat window scrolling, improved UI consistency, and better conversation management. Built on the solid foundation of the 2.0 complete rewrite.
- ๐ฎ Interactive Chat Interface: Full TUI with separate panes for chat history and input
- ๐ค Model Selection: Browse and select from available OpenAI models in real-time
- ๐ผ๏ธ Image Generation: Generate images with DALL-E using dedicated commands
- ๐พ Conversation Management: Save, load, and manage conversation history
- ๐ Clipboard Integration: Copy AI responses to system clipboard
- ๐จ Color-coded Interface: Beautiful, easy-to-read colored output
- โจ๏ธ Vim-like Controls: Command mode with printable characters entering input mode
- ๐ Input History: Navigate through previous messages with arrow keys
- ๐ Chat Scrolling: Scroll through long conversations with PgUp/PgDown
- ๐จ Smart Prompts: Dynamic prompt styling that dims when inactive
- ๐ Model Persistence: Remembers your preferred model between sessions
- ๐ Session Management: Auto-save conversations and settings
- โ Built-in Help: Comprehensive help system with keyboard shortcuts
- ๐ Version Checking: Check for updates from RubyGems
- ๐ Quiet Mode: Skip TUI for direct command-line usage in scripts
- โ๏ธ Configurable Parameters: Set max tokens, temperature, and other options
- ๐ฏ Multiple Input Methods: Type directly, load from files, or use command-line args
- ๐ Secure Configuration: API key stored in separate config file
gem install openai-termopenai# Quick question
openai -t "What is quantum computing?"
# Load from file
openai -f my_question.txt
# Generate image
openai -i -t "A beautiful sunset over mountains"
# Use specific model
openai -m gpt-4 -t "Write a poem about code"
# Quiet mode (no TUI)
openai -q -t "Quick answer needed"| Key | Action |
|---|---|
| Ctrl-Q | Quit application |
| Ctrl-M | Select AI model |
| Ctrl-H | Show help |
| Ctrl-C | Clear chat history |
| Ctrl-L | Load saved conversation |
| Ctrl-S | Save conversation |
| Ctrl-Y | Copy last AI response to clipboard |
| Ctrl-V | Show version information |
| Ctrl-I | Generate image |
| โ/โ | Navigate input history |
| PgUp/PgDn | Scroll chat window up/down |
| Any char | Start typing message |
| ESC | Cancel input (in edit mode) |
On first run, edit ~/.openai.conf:
@ai = 'your-openai-api-key-here'Get your API key from: https://platform.openai.com/api-keys
Usage: openai [options]
-f, --file FILE Load initial query from file
-t, --text TEXT Initial query text
-m, --model MODEL AI model (default: gpt-3.5-turbo)
-x, --max-tokens N Max tokens (default: 2048)
-T, --temperature N Temperature 0-2 (default: 0.7)
-i, --image Generate image instead of text
-c, --config FILE Config file path
-q, --quiet Skip TUI and output to stdout
-h, --help Display help
-v, --version Display version- Config:
~/.openai.conf- API key configuration - History:
~/.openai_history.json- Conversation history and settings
- Ruby 2.7+
- rcurses gem (~> 3.5)
- ruby-openai gem (~> 3.0)
- ๐ Chat Window Scrolling: Use PgUp/PgDown to scroll through long conversations
- ๐จ Enhanced UI Consistency: Input prompts now match chat window styling
- โซ Latest Conversations First: Conversation list now shows newest conversations at the top
- ๐ฑ๏ธ Smart Prompt Behavior: Input prompt dims when not in edit mode for better visual feedback
- Complete rewrite using rcurses for modern TUI
- Interactive chat interface with proper panes and layouts
- Real-time model selection with live preview
- Conversation management - save, load, and organize chats
- Enhanced input handling with vim-like behavior
- Clipboard integration for easy sharing
- Persistent settings - remembers your preferences
# Start the app
openai
# Type your message and press Enter
# Use Ctrl-M to change models
# Use Ctrl-S to save conversations
# Use Ctrl-L to load previous chats# Get quick answers
openai -q -t "What's 2+2?"
# Process files
openai -q -f input.txt > output.txt
# Generate images for automation
openai -i -q -t "Logo design" > image_url.txtVersion 2.0 maintains compatibility with 1.x command-line usage while adding the powerful TUI interface. Your existing scripts will continue to work, but you can now enjoy the interactive experience when running without the -q flag.
This project is public domain. Feel free to use, modify, and distribute as needed.
- Gem: https://rubygems.org/gems/openai-term
- Source: https://github.com/isene/openai
- rcurses: https://github.com/isene/rcurses
- Author: https://isene.com
Built with โค๏ธ using rcurses for an amazing terminal experience.