A professional CLI tool for interacting with OpenAI and Anthropic LLMs with cost tracking
Project description
llmctl - Command Line LLM Interface
A powerful CLI tool to interact with various LLM providers (OpenAI, Anthropic/Claude) with interactive sessions, colored output, and persistent file attachments.
โจ Features
- ๐จ Colored terminal output - Beautiful, easy-to-read interface
- ๐ฌ Interactive sessions - Keep conversations going without restarting
- ๐ File attachments - Add/remove files as context during conversations
- ๐พ Session persistence - Your conversations are saved automatically
- ๐ Multi-provider support - Switch between OpenAI and Claude seamlessly
- ๐ Conversation history - Review past exchanges in your session
- ๐ฐ Real-time cost tracking - See exact costs after every API call
- ๐ Session statistics - Track total spending per session
- ๐ Cross-platform - Works on Windows, Mac, and Linux
Installation
Via pip (Recommended)
pip install llmctl
From source
git clone https://github.com/sabbiramin113008/llmctl.git
cd llmctl
pip install -e .
Quick Start
-
Initialize llmctl:
llmctl init -
Set your API keys:
export OPENAI_API_KEY="sk-your-key-here" export ANTHROPIC_API_KEY="sk-ant-your-key-here"
-
Start chatting:
llmctl use claude:sonnet-4 llmctl interactive
Usage
๐ฎ Interactive Mode (Recommended)
Start an interactive session where you can have ongoing conversations:
llmctl interactive
Interactive Commands:
/help- Show available commands/use <provider>- Switch LLM provider (e.g.,/use gpt-4)/attach <file>- Attach a file as context/detach <file>- Remove an attached file/files- List all attached files/clear- Clear conversation history/clearfiles- Remove all attached files/history- Show conversation history/stats- Show session statistics and total costs/exitor/quit- Exit the session
Example Session:
llmctl interactive
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ llmctl - Interactive LLM Session
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก Provider: anthropic (claude-sonnet-4-20250514)
๐พ Session: default
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Quick Commands:
/help - Show all commands
/use <model> - Switch LLM provider
/attach <file> - Add file context
/stats - Show costs & usage
/exit - Exit session
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก Tip: Type naturally - no quotes needed!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฏ explain quantum computing
๐ค anthropic (claude-sonnet-4-20250514):
Quantum computing harnesses quantum mechanical phenomena...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฐ Cost Breakdown:
Model: claude-sonnet-4-20250514
Input tokens: 156 ($0.000468)
Output tokens: 423 ($0.006345)
Total tokens: 579
Total cost: $0.006813
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฏ /stats
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Session Statistics
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Session Name: default
Exchanges: 1 conversations
Total Tokens: 579
Total Cost: $0.006813
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ One-Off Questions
Ask a single question without entering interactive mode:
llmctl ask "what is fibonacci number?"
llmctl ask "write a Python function to reverse a string"
๐ Provider Management
Switch between different models:
# OpenAI models
llmctl use gpt-4
llmctl use gpt-4-turbo
llmctl use gpt-4o-mini
# Claude models
llmctl use claude:sonnet-4
llmctl use claude:sonnet-4.5
llmctl use claude:opus-4
llmctl use claude:haiku-4
๐พ Session Management
Use named sessions to keep different conversations separate:
# Start a named session
llmctl interactive --session myproject
# Start another session
llmctl interactive --session work
Sessions are stored in ~/.cllm/sessions/ and persist across restarts.
๐ File Structure
~/.cllm/
โโโ config.json # Current provider and session
โโโ sessions/
โโโ default.json # Default session
โโโ myproject.json # Named session
โโโ work.json # Another session
๐จ Color Scheme
The modern, beautiful interface features:
- Cyan - Borders and structure
- Blue - User input prompts
- Magenta - Section headers and AI labels
- Yellow - Command names and highlights
- Green - Success messages
- Red - Error messages
- Black/Default - Response text (high contrast)
Advanced Examples
Code Review Workflow
llmctl interactive --session codereview
โฏ /attach app.py
โฏ /attach utils.py
โฏ /files
๐ Attached files:
โข app.py
โข utils.py
โฏ review these files for security issues
[Assistant analyzes both files...]
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฐ Cost Breakdown:
Model: claude-sonnet-4-20250514
Input tokens: 2,847 ($0.008541)
Output tokens: 1,234 ($0.018510)
Total tokens: 4,081
Total cost: $0.027051
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฏ /stats
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Session Statistics
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Session Name: codereview
Exchanges: 1 conversations
Total Tokens: 4,081
Total Cost: $0.027051
Attached Files: 2 files
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Cost Comparison Between Models
llmctl interactive --session comparison
โฏ /use claude:haiku-4
โฏ explain neural networks in 100 words
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฐ Cost Breakdown:
Model: claude-haiku-4-20250514
Input tokens: 12 ($0.000010)
Output tokens: 95 ($0.000380)
Total tokens: 107
Total cost: $0.000390
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฏ /clear
โฏ /use gpt-4
โฏ explain neural networks in 100 words
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฐ Cost Breakdown:
Model: gpt-4
Input tokens: 12 ($0.000360)
Output tokens: 102 ($0.006120)
Total tokens: 114
Total cost: $0.006480
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Haiku is 16x cheaper! ๐
Supported Providers
OpenAI
gpt-4- Most capable, $30/$60 per 1M tokensgpt-4-turbo- Fast and capable, $10/$30 per 1M tokensgpt-4o- Optimized, $2.50/$10 per 1M tokensgpt-4o-mini- Fast and cheap, $0.15/$0.60 per 1M tokensgpt-3.5-turbo- Legacy, $0.50/$1.50 per 1M tokens
Anthropic (Claude)
sonnet-4orclaude-sonnet-4-20250514- Balanced, $3/$15 per 1M tokenssonnet-4.5orclaude-sonnet-4-5-20250929- Latest Sonnetopus-4orclaude-opus-4-20250514- Most capable, $15/$75 per 1M tokenshaiku-4orclaude-haiku-4-20250514- Fastest & cheapest, $0.80/$4 per 1M tokens
Tips & Best Practices
-
Start with cheaper models:
llmctl use claude:haiku-4 # Perfect for simple tasks
-
Attach files for context:
/attach main.py /attach config.yaml /attach README.md
-
Use named sessions for organization:
llmctl interactive --session client-work llmctl interactive --session personal-projects
-
Monitor costs regularly:
/stats # Check spending anytime
-
Clear history when switching topics:
/clear # Start fresh conversation
-
Model selection guide:
- Simple Q&A, summaries:
haiku-4orgpt-4o-mini - Code review, analysis:
sonnet-4orgpt-4o - Complex reasoning, research:
opus-4orgpt-4
- Simple Q&A, summaries:
Environment Variables
Set these in your shell profile (~/.bashrc, ~/.zshrc, etc.) for persistence:
# Add to ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="sk-your-key-here"
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
Then reload:
source ~/.bashrc # or source ~/.zshrc
Troubleshooting
Colors not showing?
Colorama is installed automatically. If colors don't work:
pip install --upgrade colorama
API key errors?
Verify keys are set:
echo $OPENAI_API_KEY
echo $ANTHROPIC_API_KEY
Command not found?
Ensure Python scripts directory is in PATH:
# Add to ~/.bashrc or ~/.zshrc
export PATH="$HOME/.local/bin:$PATH"
Session not saving?
Check permissions:
ls -la ~/.cllm/
chmod 755 ~/.cllm
Development
Install in development mode:
git clone https://github.com/sabbiramin113008/llmctl.git
cd llmctl
pip install -e .
Run tests:
pytest tests/
Build package:
python -m build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
SM Sabbir Amin - GitHub
Acknowledgments
- OpenAI for the GPT API
- Anthropic for the Claude API
- The Python community for amazing tools
Support
- ๐ Report bugs
- ๐ก Request features
- โญ Star this repo if you find it useful!
Made with โค๏ธ by developers, for developers
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmctl-0.1.8.tar.gz.
File metadata
- Download URL: llmctl-0.1.8.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb72e966546b5fb47fda47b29438de06da4d95d284ae408d7de3b81e5e19b4dd
|
|
| MD5 |
e07ec7c2632a40f09c8a343c5586862e
|
|
| BLAKE2b-256 |
7a3caa3b3b01b92fc5cb6853ce619ff427ee19eb34eb8a23b17a56e17cc5a06f
|
File details
Details for the file llmctl-0.1.8-py3-none-any.whl.
File metadata
- Download URL: llmctl-0.1.8-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45abcca5fb6659d0211fbf77c798654e36d144b061ce33eb705532518919ab26
|
|
| MD5 |
de3593c401d927c83611a814038f90cc
|
|
| BLAKE2b-256 |
02e097a5752644f6f8d7ea366772c394a0287dfdd443d40f4b938fc71336290a
|