diff --git a/.env b/.env deleted file mode 100644 index 55946eb..0000000 --- a/.env +++ /dev/null @@ -1,73 +0,0 @@ -# OpenRouter API Configuration -OPENROUTER_API_KEY= - -############### OpenRouter Model Configuration ############### - -# If you want to use a specific model, uncomment one of the lines below. -# If not set (or all are commented), it will default to "mistralai/mistral-small-3.2-24b-instruct:free" -# You can also set it to any model available on OpenRouter: https://openrouter.ai/models -# Uncomment ONE of the following lines to use a specific free model: -# The Default model (used when no model is specified) is mistralai/mistral-small-3.2-24b-instruct:free -# Additional free models commonly available on OpenRouter : - -#OPENROUTER_MODEL=agentica-org/deepcoder-14b-preview:free -#OPENROUTER_MODEL=arliai/qwq-32b-arliai-rpr-v1:free -#OPENROUTER_MODEL=cognitivecomputations/dolphin-mistral-24b-venice-edition:free -#OPENROUTER_MODEL=cognitivecomputations/dolphin3.0-mistral-24b:free -#OPENROUTER_MODEL=cognitivecomputations/dolphin3.0-r1-mistral-24b:free -#OPENROUTER_MODEL=deepseek/deepseek-chat:free -#OPENROUTER_MODEL=deepseek/deepseek-chat-v3-0324:free -#OPENROUTER_MODEL=deepseek/deepseek-r1-0528:free -#OPENROUTER_MODEL=deepseek/deepseek-r1-0528-qwen3-8b:free -#OPENROUTER_MODEL=deepseek/deepseek-r1-distill-llama-70b:free -#OPENROUTER_MODEL=deepseek/deepseek-r1-distill-qwen-14b:free -#OPENROUTER_MODEL=deepseek/deepseek-r1:free -#OPENROUTER_MODEL=deepseek/deepseek-v3-base:free -#OPENROUTER_MODEL=featherless/qwerky-72b:free -#OPENROUTER_MODEL=google/gemini-2.0-flash-exp:free -#OPENROUTER_MODEL=google/gemini-2.5-pro-exp-03-25 -#OPENROUTER_MODEL=google/gemma-2-9b-it:free -#OPENROUTER_MODEL=google/gemma-3-12b-it:free -#OPENROUTER_MODEL=google/gemma-3-27b-it:free -#OPENROUTER_MODEL=google/gemma-3-4b-it:free -#OPENROUTER_MODEL=google/gemma-3n-e2b-it:free -#OPENROUTER_MODEL=google/gemma-3n-e4b-it:free -#OPENROUTER_MODEL=microsoft/mai-ds-r1:free -#OPENROUTER_MODEL=mistralai/devstral-small-2505:free -#OPENROUTER_MODEL=mistralai/mistral-7b-instruct:free -#OPENROUTER_MODEL=mistralai/mistral-nemo:free -#OPENROUTER_MODEL=mistralai/mistral-small-24b-instruct-2501:free -#OPENROUTER_MODEL=mistralai/mistral-small-3.1-24b-instruct:free -#OPENROUTER_MODEL=mistralai/mistral-small-3.2-24b-instruct:free -#OPENROUTER_MODEL=moonshotai/kimi-dev-72b:free -#OPENROUTER_MODEL=moonshotai/kimi-vl-a3b-thinking:free -#OPENROUTER_MODEL=meta-llama/llama-3.1-405b-instruct:free -#OPENROUTER_MODEL=meta-llama/llama-3.2-11b-vision-instruct:free -#OPENROUTER_MODEL=meta-llama/llama-3.2-3b-instruct:free -#OPENROUTER_MODEL=meta-llama/llama-3.3-70b-instruct:free -#OPENROUTER_MODEL=meta-llama/llama-4-maverick:free -#OPENROUTER_MODEL=meta-llama/llama-4-scout:free -#OPENROUTER_MODEL=nousresearch/deephermes-3-llama-3-8b-preview:free -#OPENROUTER_MODEL=nvidia/llama-3.1-nemotron-ultra-253b-v1:free -#OPENROUTER_MODEL=nvidia/llama-3.3-nemotron-super-49b-v1:free -#OPENROUTER_MODEL=openai/gpt-oss-20b:free -#OPENROUTER_MODEL=openrouter/cypher-alpha:free -#OPENROUTER_MODEL=qwen/qwen-2.5-72b-instruct:free -#OPENROUTER_MODEL=qwen/qwen-2.5-coder-32b-instruct:free -#OPENROUTER_MODEL=qwen/qwen3-14b:free -#OPENROUTER_MODEL=qwen/qwen3-30b-a3b:free -#OPENROUTER_MODEL=qwen/qwen3-32b:free -#OPENROUTER_MODEL=qwen/qwen3-4b:free -#OPENROUTER_MODEL=qwen/qwen3-8b:free -#OPENROUTER_MODEL=qwen/qwen3-235b-a22b:free -#OPENROUTER_MODEL=qwen/qwen2.5-vl-32b-instruct:free -#OPENROUTER_MODEL=qwen/qwen2.5-vl-72b-instruct:free -#OPENROUTER_MODEL=qwen/qwq-32b:free -#OPENROUTER_MODEL=rekai/reka-flash-3:free -#OPENROUTER_MODEL=sarvamai/sarvam-m:free -#OPENROUTER_MODEL=shisa-ai/shisa-v2-llama3.3-70b:free -#OPENROUTER_MODEL=tencent/hunyuan-a13b-instruct:free -#OPENROUTER_MODEL=thudm/glm-4-32b:free -#OPENROUTER_MODEL=thudm/glm-z1-32b:free -#OPENROUTER_MODEL=tngtech/deepseek-r1t-chimera:free -#OPENROUTER_MODEL=tngtech/deepseek-r1t2-chimera:free diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7e08b38 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# OpenRouter API Configuration +OPENROUTER_API_KEY= + +# OpenRouter Model Configuration +OPENROUTER_MODEL= diff --git a/.gitignore b/.gitignore index 8855adc..3274b32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Ignore chat session logs chat_sessions/ .DS_Store + +# Ignore user-edited config files +.env # Common log files *.log diff --git a/.models b/.models new file mode 100644 index 0000000..4dcb107 --- /dev/null +++ b/.models @@ -0,0 +1,71 @@ +##################################################### +# DO NOT EDIT THIS FILE AS IT WILL BREAKE THE UPDATES +##################################################### + +############### OpenRouter Modes ############### +# If you want to use a specific model, copy one of the lines below and put it in the OPENROUTER_MODEL= of your .env file. +# If not set, it will default to "OPENROUTER_MODEL=mistralai/mistral-small-3.2-24b-instruct:free" +# You can also set it to any model available on OpenRouter: https://openrouter.ai/models +# Additional free models commonly available on OpenRouter : + +agentica-org/deepcoder-14b-preview:free +arliai/qwq-32b-arliai-rpr-v1:free +cognitivecomputations/dolphin-mistral-24b-venice-edition:free +cognitivecomputations/dolphin3.0-mistral-24b:free +cognitivecomputations/dolphin3.0-r1-mistral-24b:free +deepseek/deepseek-chat:free +deepseek/deepseek-chat-v3-0324:free +deepseek/deepseek-r1-0528:free +deepseek/deepseek-r1-0528-qwen3-8b:free +deepseek/deepseek-r1-distill-llama-70b:free +deepseek/deepseek-r1-distill-qwen-14b:free +deepseek/deepseek-r1:free +deepseek/deepseek-v3-base:free +featherless/qwerky-72b:free +google/gemini-2.0-flash-exp:free +google/gemini-2.5-pro-exp-03-25 +google/gemma-2-9b-it:free +google/gemma-3-12b-it:free +google/gemma-3-27b-it:free +google/gemma-3-4b-it:free +google/gemma-3n-e2b-it:free +google/gemma-3n-e4b-it:free +microsoft/mai-ds-r1:free +mistralai/devstral-small-2505:free +mistralai/mistral-7b-instruct:free +mistralai/mistral-nemo:free +mistralai/mistral-small-24b-instruct-2501:free +mistralai/mistral-small-3.1-24b-instruct:free +mistralai/mistral-small-3.2-24b-instruct:free +moonshotai/kimi-dev-72b:free +moonshotai/kimi-vl-a3b-thinking:free +meta-llama/llama-3.1-405b-instruct:free +meta-llama/llama-3.2-11b-vision-instruct:free +meta-llama/llama-3.2-3b-instruct:free +meta-llama/llama-3.3-70b-instruct:free +meta-llama/llama-4-maverick:free +meta-llama/llama-4-scout:free +nousresearch/deephermes-3-llama-3-8b-preview:free +nvidia/llama-3.1-nemotron-ultra-253b-v1:free +nvidia/llama-3.3-nemotron-super-49b-v1:free +openai/gpt-oss-20b:free +openrouter/cypher-alpha:free +qwen/qwen-2.5-72b-instruct:free +qwen/qwen-2.5-coder-32b-instruct:free +qwen/qwen3-14b:free +qwen/qwen3-30b-a3b:free +qwen/qwen3-32b:free +qwen/qwen3-4b:free +qwen/qwen3-8b:free +qwen/qwen3-235b-a22b:free +qwen/qwen2.5-vl-32b-instruct:free +qwen/qwen2.5-vl-72b-instruct:free +qwen/qwq-32b:free +rekai/reka-flash-3:free +sarvamai/sarvam-m:free +shisa-ai/shisa-v2-llama3.3-70b:free +tencent/hunyuan-a13b-instruct:free +thudm/glm-4-32b:free +thudm/glm-z1-32b:free +tngtech/deepseek-r1t-chimera:free +tngtech/deepseek-r1t2-chimera:free diff --git a/README.md b/README.md index 03b586b..dcb421b 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,20 @@ Please note that free models on openrouter.ai (those with :free in their slug) a ## Features - ๐Ÿš€ Minimalist CLI interface โ€” talk to AI directly from your terminal. - - ๐Ÿ”‘ Secure API key & model config โ€” stored in .env file, no need to enter every time. + - ๐Ÿ”‘ Secure API key & model config โ€” stored in .env file (create it by copiing .env.example), no need to enter every time. + - ๐Ÿ”„ Easy update: Run `ai.sh --update` to get the latest version. + - ๐Ÿ“– Built-in help: Run `ai.sh --help` for usage instructions. - ๐Ÿค– Full session memory โ€” ongoing conversations with proper context (stateful chat). - ๐Ÿ’ฌ Natural language queries โ€” just type like you're talking to a buddy. - - ๐Ÿ’พ Chat history saved โ€” all conversations stored as timestamped .txt files inside chat_sessions/. + - ๐Ÿ’พ Chat history saved โ€” all conversations stored as timestamped .txt files inside `chat_sessions/`. - ๐Ÿง  Dynamic AI name display โ€” bot replies are labeled with the selected model (e.g. Mistral AI:). - ๐Ÿ‘ค Personalized & interactive input โ€” uses your system username in the prompt and supports arrow keys for editing your message like a real terminal app. - ๐Ÿงน Clean output โ€” only the answer, no JSON noise. - - ๐Ÿ†“ Uses a free model by default โ€” no paid account required. - - ๐Ÿ” 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). - - ๐Ÿงช Works on Linux & macOS โ€” tested on Arch-based, Debian-based and macOS (via brew). - - โœจ Zero dependencies beyond curl + jq โ€” no Python, no Node.js, no drama. - - ๐Ÿž Debug mode support โ€” run with DEBUG=true to see full raw API responses on errors in the terminal. + - ๐Ÿ†“ Uses a free model by default โ€” no paid account required only your API key. + - ๐Ÿ” 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)`. + - ๐Ÿงช Works on Linux & macOS and Windows through WLS โ€” tested on Arch-based, Debian-based and macOS (via brew). + - โœจ Zero dependencies beyond `curl` and `jq` โ€” no Python, no Node.js, no drama. + - ๐Ÿž Debug mode support โ€” run with `DEBUG=true ai.sh` to see full raw API responses on errors in the terminal. - ๐Ÿงผ Session history is always clean โ€” error messages are never saved in the logs, whether debug mode is on or off (default). ### Important Note @@ -79,8 +81,9 @@ sudo apt install jq - Generate a new API key 4. **Configure your API key and model:** - - while you are in the openrouter folder, edit the `.env` file template and add your API key: + - Copy the example environment file and edit it: ```bash + cp .env.example .env vim .env ``` - Add your API key and optionally configure the model: @@ -90,8 +93,21 @@ sudo apt install jq # OpenRouter Model Configuration (optional - leave empty for default) OPENROUTER_MODEL= ``` + - See `.models` for a list of available models. Do not edit `.models` directly. ## Usage + +### Update & Help + +- To update the script to the latest version: + ```bash + ./ai.sh --update + ``` + +- To show usage instructions: + ```bash + ./ai.sh --help + ``` ## Creating a Terminal Alias (Recommended) For easier access, you can create an alias so you can use the script from anywhere without typing the full path: @@ -192,20 +208,17 @@ $ DEBUG=true ai ### Changing the AI Model -You can change the AI model by editing the `OPENROUTER_MODEL` variable in your `.env` file. The `.env` file now includes a comprehensive list of free models - simply uncomment the one you want to use: +You can change the AI model by editing the `OPENROUTER_MODEL` variable in your `.env` file. For available models, refer to the `.models` file in the repository root. Copy the desired model slug from `.models` and set it in your `.env`: ```bash # Leave empty or unset to use the default model OPENROUTER_MODEL= -# Or uncomment one of the many free models listed in .env -# OPENROUTER_MODEL=qwen/qwq-32b:free -# OPENROUTER_MODEL=deepseek/deepseek-r1-0528:free -# OPENROUTER_MODEL=google/gemini-2.0-flash-exp:free +# Example: +OPENROUTER_MODEL=qwen/qwq-32b:free ``` -Check your `.env` file for the complete list. -**Note:** If `OPENROUTER_MODEL` is not set or left empty, the script will use the default Mistral model. Simply uncomment one of the free models in your `.env` file to use a different model. +**Note:** If `OPENROUTER_MODEL` is not set or left empty, the script will use the default Mistral model. Do not edit `.models` directly. ### Common Issues diff --git a/ai.sh b/ai.sh index e43a19a..98389cc 100755 --- a/ai.sh +++ b/ai.sh @@ -5,6 +5,27 @@ # Optional: Run with DEBUG=true to enable detailed error debugging, e.g.: # DEBUG=true ./ai.sh + +# Option handling with case statement +case "$1" in + -u|--update) + echo "๐Ÿ”„ Updating ai.sh to the latest version..." + cd "$SCRIPT_DIR" && git pull + exit $? + ;; + -h|--help) + echo -e "\nOpenRouter CLI Chat Usage:\n" + echo " ./ai.sh Start interactive chat" + echo " ./ai.sh --update Update repository (git pull)" + echo " ./ai.sh -h, --help Show this help message" + echo -e "\nEnvironment setup:" + echo " cp .env.example .env # Create your .env file" + echo " Edit .env and add your OPENROUTER_API_KEY and optionally OPENROUTER_MODEL." + echo " See .models for available models." + exit 0 + ;; +esac + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Check if a command exists; if missing, suggest how to install its package based on detected package manager