You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-36Lines changed: 56 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,19 +5,24 @@ Simple terminal app to use OpenRouter.ai with your personal API keys. Ask questi
5
5
Please note that free models on openrouter.ai (those with :free in their slug) are typically limited to 50 requests per day if you have not purchased credits. A request on OpenRouter.ai is defined as a single API call or message sent to the model—essentially, each question or prompt you send, regardless of its length or the number of tokens involved. For 99% of people using this script, is more that enough. These limits apply per account, not per model. Switching between free models does not reset your daily quota. Please read their documentation for more: https://openrouter.ai/settings/credits
6
6
7
7
## Features
8
-
9
-
- 🚀 Simple command-line interface
10
-
- 🔑 Secure API key and model management with `.env` file
11
-
- 🎯 Clean output (only the AI response, no JSON clutter)
12
-
- 💬 Natural language queries
13
-
- 🆓 Uses free Mistral model by default
14
-
- ⚡ **Stateless design** - each query is independent (no conversation history between queries)
15
-
- 📝 **Conversation History Storage** - All chat sessions are saved as text files in the `chat_sessions` folder for later reference
8
+
- 🚀 Minimalist CLI interface — talk to AI directly from your terminal.
9
+
- 🔑 Secure API key & model config — stored in .env file, no need to enter every time.
10
+
- 🤖 Full session memory — ongoing conversations with proper context (stateful chat).
11
+
- 💬 Natural language queries — just type like you're talking to a buddy.
12
+
- 💾 Chat history saved — all conversations stored as timestamped .txt files inside chat_sessions/.
13
+
- 🧠 Dynamic AI name display — bot replies are labeled with the selected model (e.g. Mistral AI:).
14
+
- 👤 Personalized & interactive input — uses your system username in the prompt and supports arrow keys for editing your message like a real terminal app.
15
+
- 🧹 Clean output — only the answer, no JSON noise.
16
+
- 🆓 Uses a free model by default — no paid account required.
17
+
- 🔍 Smart package manager detection — if curl or jq is missing, the script tells you exactly how to install it (e.g. sudo pacman -S jq).
18
+
- 🧪 Works on Linux & macOS — tested on Arch-based, Debian-based and macOS (via brew).
19
+
- ✨ Zero dependencies beyond curl + jq — no Python, no Node.js, no drama.
20
+
- 🐞 Debug mode support — run with DEBUG=true to see full raw API responses on errors in the terminal.
21
+
- 🧼 Session history is always clean — error messages are never saved in the logs, whether debug mode is on or off (default).
16
22
17
23
### Important Note
18
-
19
-
This tool is designed for **single-question interactions** - each query is independent with no memory of previous conversations (Stateless design). However, it **stores conversation history** for your convenience. Each time you run the script, it saves both your question and the AI's response to text files in the `chat_sessions` folder. The files are named using the first sentence of your question, making it easy to find and review previous conversations. If you ask the exact same question again, the new response will be appended to the existing file.
20
-
24
+
This CLI tool now supports ongoing, contextual chat with the AI.
25
+
Unlike the old one-shot version (ask once, get one reply), this new version maintains the full conversation history during a session — so you can chat back and forth naturally, with context.
21
26
22
27
## Prerequisites
23
28
@@ -88,37 +93,53 @@ sudo apt install jq
88
93
89
94
## Usage
90
95
91
-
### Basic Usage
96
+
### Basic Usage with Sample Output
92
97
93
98
```bash
94
-
./ai.sh your question here
95
-
```
96
-
### Examples
99
+
./ai.sh
97
100
98
-
```bash
99
-
# Ask a simple question
100
-
./ai.sh what is the meaning of life
101
+
💬 Start a conversation! Type your message and press Enter (Ctrl+C to exit)
102
+
103
+
🧑 cerebrux: What's the capital of Greece?
101
104
102
-
# Ask for coding help
103
-
./ai.sh how do I create a functionin Python
105
+
🤖 Mistral AI:
106
+
Athens is both the historical heart and the modern capital of Greece
104
107
105
-
# Ask for a definition
106
-
./ai.sh define recursion
108
+
🧑 cerebrux: Did they have a co-capital there?
107
109
108
-
# Note for zsh users: If your question ends with a ?, make sure to wrap it in quotes
109
-
./ai.sh "what is the meaning of life?"
110
+
🤖 Mistral AI:
111
+
Thessaloniki is widely recognized as Greece's "second city" due to its size and economic
112
+
power.
113
+
The term "co-capital" (**συμπρωτεύουσα** - symprotévousa) when applied to Thessaloniki
114
+
is an honorary, historical, and cultural designation reflecting its immense importance.
110
115
```
116
+
### Showing Error Messages with DEBUG true/false(deafult)
117
+
```bash
118
+
➜ openrouter.ai git:(main) ✗ DEBUG=true ./ai.sh
111
119
112
-
### Sample Output
120
+
💬 Start a conversation! Type your message and press Enter (Ctrl+C for exit)
113
121
114
-
```bash
115
-
$ ./ai.sh what is the meaning of 42
116
-
🤖 AI response:
122
+
🧑 cerebrux: Hi!
117
123
118
-
The number **42** has gained fame as the "Answer to the Ultimate Question of Life, the Universe,
119
-
and Everything"in*The Hitchhiker's Guide to the Galaxy* by **Douglas Adams**.
124
+
❌ API Error: No auth credentials found
125
+
126
+
🔍 Full response for debugging:
127
+
{
128
+
"error": {
129
+
"message": "No auth credentials found",
130
+
"code": 401
131
+
}
132
+
}
120
133
```
134
+
```bash
135
+
➜ openrouter.ai git:(main) ✗ ./ai.sh
136
+
137
+
💬 Start a conversation! Type your message and press Enter (Ctrl+C for exit)
138
+
139
+
🧑 cerebrux: Hi!
121
140
141
+
❌ API Error: No auth credentials found
142
+
```
122
143
## Creating a Terminal Alias (Recommended)
123
144
124
145
For easier access, you can create an alias so you can use the script from anywhere without typing the full path:
@@ -207,14 +228,13 @@ Check your `.env` file for the complete list.
207
228
- Check your internet connection
208
229
- Ensure you haven't exceeded any rate limits
209
230
210
-
### Debug Mode
231
+
### 🐛 Debug Mode
211
232
212
-
The script automatically shows the full JSON response when it encounters errors or unexpected responses. If you need to see the raw API response for debugging purposes, the script will display it when:
213
-
- The API returns an error
214
-
- The response format is unexpected
215
-
- The content cannot be extracted properly
233
+
To enable raw API response output for troubleshooting, run the script with:
216
234
217
-
This provides all the debugging information you need without manually modifying the script.
0 commit comments