Package Exports
- openrouter-terminal
- openrouter-terminal/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openrouter-terminal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
██████╗ ██████╗ ███████╗███╗ ██╗██████╗ ██████╗ ██╗ ██╗████████╗███████╗██████╗
██╔═══██╗██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔═══██╗██║ ██║╚══██╔══╝██╔════╝██╔══██╗
██║ ██║██████╔╝█████╗ ██╔██╗ ██║██████╔╝██║ ██║██║ ██║ ██║ █████╗ ██████╔╝
██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║██╔══██╗██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗
╚██████╔╝██║ ███████╗██║ ╚████║██║ ██║╚██████╔╝╚██████╔╝ ██║ ███████╗██║ ██║
╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗
╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║
██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║
██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║██║██║╚██╗██║██╔══██║██║
██║ ███████╗██║ ██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║███████╗
╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ A command-line interface for chatting with AI models via OpenRouter. Features streaming responses, tool/function calling, session management, file context, and token/cost tracking.
Features
- Streaming Responses - Real-time token streaming for instant feedback
- Tool/Function Calling - Extend AI capabilities with custom JavaScript tools
- Session Management - Save, load, and branch conversations
- File Context - Attach files to provide context to the AI
- Token and Cost Tracking - Monitor usage and spending per message and session
- Model Browser - Browse and select from hundreds of available models
- Persistent Config - Settings saved to
~/.config/openrouter-terminal/
Installation
From npm
npm install -g openrouter-terminalFrom GitHub Releases
Download the pre-built binary for your platform from the Releases page.
Linux (x64):
curl -L https://github.com/Cr0wn-Gh0ul/OpenRouter-Terminal/releases/latest/download/openrouter-linux-x64 -o openrouter
chmod +x openrouter
sudo mv openrouter /usr/local/bin/Linux (ARM64):
curl -L https://github.com/Cr0wn-Gh0ul/OpenRouter-Terminal/releases/latest/download/openrouter-linux-arm64 -o openrouter
chmod +x openrouter
sudo mv openrouter /usr/local/bin/macOS (Apple Silicon):
curl -L https://github.com/Cr0wn-Gh0ul/OpenRouter-Terminal/releases/latest/download/openrouter-darwin-arm64 -o openrouter
chmod +x openrouter
sudo mv openrouter /usr/local/bin/macOS (Intel):
curl -L https://github.com/Cr0wn-Gh0ul/OpenRouter-Terminal/releases/latest/download/openrouter-darwin-x64 -o openrouter
chmod +x openrouter
sudo mv openrouter /usr/local/bin/Build from Source
Requires Node.js 20 or later.
git clone https://github.com/Cr0wn-Gh0ul/OpenRouter-Terminal.git
cd OpenRouter-Terminal
npm install
npm run build
npm linkTo build a standalone executable:
npm run build:sea
# Binary will be in bin/Quick Start
Get an API key from OpenRouter
Set your API key:
openrouter -k your-api-key-hereStart chatting:
openrouter
Usage
Command Line Options
openrouter [options]
Options:
-V, --version Output version number
-k, --api-key <key> Set OpenRouter API key
-m, --model <model> Use a specific model
-p, --system <prompt> Set a system prompt
-o, --oneshot <message> Send a single message and exit
-c, --config Show current configuration
-t, --tools List registered tools
-x, --context Show files in context
-l, --load <file> Load a saved session
-s, --session <name> Use a named session (auto-saves)
--sessions List all saved sessions
-h, --help Display helpExamples
# Start interactive chat
openrouter
# Send a quick one-shot message
openrouter -o "Explain quantum computing in simple terms"
# Use a specific model
openrouter -m anthropic/claude-sonnet-4
# Set a custom system prompt
openrouter -p "You are a helpful coding assistant"
# Start with a named session (auto-saves after each message)
openrouter -s myproject
# Load a previously saved session
openrouter -l myprojectInteractive Commands
Type help in interactive mode to see all available commands:
| Category | Command | Description |
|---|---|---|
| General | help |
Show help message |
clear |
Clear conversation history | |
usage |
Show token/cost usage for session | |
exit, quit |
Exit the chat | |
| Model | model |
Show current model |
model <name> |
Switch to a different model | |
models |
Browse and select from available models | |
| Context | context |
Show files in context |
context <file...> |
Add file(s) to message context | |
context clear |
Clear all context files | |
| Tools | tools |
List registered tools |
tools add <path> |
Add a tool file or directory | |
| Sessions | sessions |
List all saved sessions |
save <name> |
Save conversation to a session file | |
save <name> md |
Export conversation as Markdown | |
load <name> |
Load a saved session | |
history |
Show conversation history | |
branch <n> |
Rewind to message N (for branching) | |
| Config | config |
Show current configuration |
system <prompt> |
Set a new system prompt | |
key <apikey> |
Set and save API key |
Tools (Function Calling)
Extend the AI's capabilities with custom tools. Tools are JavaScript modules that the AI can call during conversations.
Adding Tools
Via interactive mode:
> tools add /path/to/tools
Added tool path: /path/to/tools
Loaded 3 new tool(s). Total: 3 custom tools.Via config file (~/.config/openrouter-terminal/config.json):
{
"toolPaths": ["/path/to/tools", "/path/to/specific/tool.js"]
}Creating Tools
// my_tool.js
export default {
name: 'my_tool',
description: 'Description for the AI to understand when to use it',
parameters: {
type: 'object',
properties: {
param1: { type: 'string', description: 'First parameter' },
param2: { type: 'number', description: 'Second parameter' },
},
required: ['param1'],
},
execute: async (args) => {
const { param1, param2 } = args;
// Do something...
return 'Result as a string';
},
};See examples/tools/ for sample tools including:
- get_time.js - Get current date/time in various formats and timezones
- calculator.js - Perform basic arithmetic calculations
Session Management
Named Sessions (Auto-Save)
Start with a named session to automatically save after each message:
openrouter -s myprojectManual Save/Load
> save research
Session saved: ~/.config/openrouter-terminal/sessions/research.json
> save research md
Session saved as Markdown: ~/.config/openrouter-terminal/sessions/research.md
> load research
Loaded session: researchConversation Branching
Go back to any point in the conversation and branch off:
> history
[0] system: You are a helpful assistant...
[1] user: Write a story about a robot
[2] assistant: Once upon a time...
[3] user: Make it scarier
[4] assistant: The robot's eyes glowed red...
> branch 2
Rewound to message 2. Conversation branched.
> Make it funnier insteadToken and Cost Tracking
Every message shows token usage and cost:
(anthropic/claude-sonnet-4)> Hello!
Hello! How can I help you today?
[1.2K in, 45 out | $0.0023]View session totals with the usage command:
> usage
Session Usage:
Messages: 5
Tokens: 12.3K in, 3.2K out (15.5K total)
Cost: $0.0234Configuration
Configuration is stored at ~/.config/openrouter-terminal/config.json:
{
"apiKey": "sk-or-...",
"model": "anthropic/claude-sonnet-4",
"systemPrompt": "You are a helpful assistant",
"toolPaths": ["/path/to/tools"],
"contextPaths": ["/path/to/file.txt"]
}Sessions are stored at ~/.config/openrouter-terminal/sessions/.
License
MIT