npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

openrouter-cli

v1.2.0

Published

A powerful command-line interface for interacting with multiple AI models through OpenRouter's unified API

Readme

OpenRouter CLI (ORC)

A powerful command-line interface for interacting with multiple AI models through OpenRouter unified API.

Features

  • 🤖 Multi-Model Support: Query multiple AI models simultaneously
  • 💬 Interactive Chat: Engage in conversations with context retention
  • 👤 Profile Management: Save and switch between different model configurations
  • 🎨 Beautiful Output: Color-coded responses with model identification
  • Streaming Responses: Real-time streaming for immediate feedback
  • 🔧 Flexible Configuration: Customize temperature, max tokens, and more
  • 📝 Template System: Create reusable prompt templates for common tasks
  • 🔄 Batch Processing: Process multiple prompts from files
  • 🔗 Prompt Chaining: Chain outputs from one prompt as input to another
  • 📤 Export/Import: Export conversations to multiple formats and import from other platforms
  • 💻 Code Integration: Analyze code files and git diffs directly

Installation

npm install -g openrouter-cli

After installation, the CLI will be available as orc.

Quick Start

  1. Set your OpenRouter API key:

    orc config set apiKey YOUR_API_KEY
  2. Ask a question:

    orc ask "What is the meaning of life?"
  3. Start an interactive chat:

    orc chat

📚 Documentation

🎯 Featured Examples

Multi-Model Comparison

# Compare responses from multiple models
orc ask "Explain quantum computing" --models gpt-4-turbo claude-3-opus gemini-pro

Code Analysis

# Analyze code files directly
orc ask "Review this code for security issues" --file app.js --profile security

Batch Processing

# Process multiple prompts from a file
orc batch questions.txt --models gpt-4 claude-3 --output answers.md --format markdown

Prompt Chaining

# Chain prompts for complex workflows
orc chain --models gpt-4 \
  --steps \
    "Write a blog outline about {input}" \
    "Expand the outline into a full post: {input}" \
    "Create SEO metadata: {input}"

Commands

Configuration

# Set API key
orc config set apiKey YOUR_API_KEY

# View current configuration
orc config get

# Set a specific configuration value
orc config set <key> <value>

Asking Questions

# Ask a single question using default profile
orc ask "Your question here"

# Use a specific model
orc ask "Your question" --model claude-3-opus-20240229

# Use a specific profile
orc ask "Your question" --profile creative

# Use a template
orc ask "Review this code" --template code-review

# Include file content
orc ask "Explain this code" --file script.py

# Include multiple files
orc ask "Compare these implementations" --files file1.js file2.js

Interactive Chat

# Start chat with default profile
orc chat

# Start chat with specific profile
orc chat --profile technical

# Start chat with specific model
orc chat --model gpt-4-turbo

Chat Commands:

  • /help - Show available commands
  • /models - List and select active models
  • /profile [name] - Switch profile
  • /history - Show conversation history
  • /clear - Clear conversation history
  • /exit - Exit chat

Input Behavior:

  • Press Enter once to send single-line messages
  • Press Enter on an empty line to start multiline mode
  • In multiline mode, press Enter twice to send

Model Management

# List all available models
orc models list

# Search for specific models
orc models search gpt

# Get detailed information about a model
orc models info gpt-4-turbo

Profile Management

# List all profiles
orc profile list

# Create a new profile
orc profile create myprofile

# Update a profile
orc profile update myprofile

# Delete a profile
orc profile delete myprofile

# Set default profile
orc profile set-default myprofile

Template Management

# Create a new template
orc template create code-review \
  --system "You are a code reviewer" \
  --prompt "Review the following code: {prompt}" \
  --models gpt-4-turbo claude-3-opus-20240229 \
  --temperature 0.3

# List all templates
orc template list

# Delete a template
orc template delete code-review

Batch Processing

# Process prompts from a file (one prompt per line)
orc batch prompts.txt --models gpt-4-turbo claude-3-haiku-20240307

# Save results to a file
orc batch prompts.txt --output results.json

# Export as markdown
orc batch prompts.txt --output results.md --format markdown

# Export as CSV
orc batch prompts.txt --output results.csv --format csv

Prompt Chaining

# Chain prompts together (interactive)
orc chain --steps "Summarize this: {input}" "Extract key points: {input}" "Create action items: {input}"

# The chain command will:
# 1. Ask for initial input
# 2. Process through each step
# 3. Use output from each step as input for the next

Export/Import Conversations

# Export conversation to different formats
orc export markdown conversation.md --conversation chat-history.json
orc export html conversation.html --conversation chat-history.json --syntax-highlight
orc export json conversation.json --conversation chat-history.json --include-metadata

# Import from other platforms
orc import chatgpt-export.json --type chatgpt
orc import claude-export.json --type claude
orc import generic-chat.json --type generic

Code Integration

# Analyze git changes
orc git-diff              # Analyze changes since last commit
orc git-diff HEAD~3       # Analyze last 3 commits
orc git-diff main         # Compare with main branch

# The git-diff command will:
# 1. Show changed files and statistics
# 2. Ask what you want to know about the changes
# 3. Provide AI analysis of the diff

Profiles

Profiles allow you to save different configurations for different use cases:

  • Models: List of models to query
  • Temperature: Control randomness (0.0 - 2.0)
  • Max Tokens: Maximum response length
  • System Prompt: Optional system message

Default Profiles

The CLI comes with several pre-configured profiles:

  • default: Balanced general-purpose models
  • fast: Quick responses with efficient models
  • creative: Higher temperature for creative tasks
  • technical: Focused on accuracy and code generation

Examples

Basic Usage

# Simple question
orc ask "Explain quantum computing in simple terms"

# Code generation
orc ask "Write a Python function to calculate fibonacci numbers" --profile technical

# Creative writing
orc ask "Write a haiku about programming" --profile creative

Multi-Model Comparison

# Compare responses from multiple models
orc ask "What are the pros and cons of TypeScript?" --profile default

Advanced Examples

Using Templates

# Create a code review template
orc template create code-review \
  --system "You are an expert code reviewer. Focus on best practices, security, and performance." \
  --prompt "Please review the following code:\n\n{prompt}\n\nProvide feedback on:\n1. Code quality\n2. Potential bugs\n3. Performance issues\n4. Security concerns" \
  --models gpt-4-turbo claude-3-opus-20240229 \
  --temperature 0.3

# Use the template with a file
orc ask "Review for production readiness" --template code-review --file app.js

Batch Processing

Create a file prompts.txt:

Explain the concept of recursion
Write a quicksort implementation in Python
What are the SOLID principles?
Compare REST vs GraphQL

Then process all prompts:

orc batch prompts.txt --models gpt-4-turbo claude-3-haiku-20240307 --output results.md --format markdown

Prompt Chaining Example

# Create a content pipeline
orc chain \
  --steps \
  "Write a 200-word article about {input}" \
  "Extract 5 key points from this article: {input}" \
  "Create a Twitter thread from these points: {input}" \
  --models claude-3-opus-20240229

# When prompted, enter: "artificial intelligence in healthcare"
# The chain will:
# 1. Write an article about AI in healthcare
# 2. Extract key points from the article
# 3. Create a Twitter thread from those points

Code Analysis

# Analyze a specific file with context
orc ask "Explain the main functionality and suggest improvements" \
  --file src/utils/auth.js \
  --models gpt-4-turbo

# Compare multiple implementations
orc ask "Compare these sorting algorithms and explain their trade-offs" \
  --files sort-bubble.py sort-quick.py sort-merge.py

# Analyze recent git changes
orc git-diff HEAD~5 --models claude-3-opus-20240229
# Then when prompted: "What are the main changes and their impact on the codebase?"

Interactive Chat Session

# Start a chat session
orc chat

# In chat:
You: Can you help me understand recursion?
[Model responds...]

You: Can you show me an example in JavaScript?
[Model responds with code...]

You: /models
[Select different models]

You: /exit

Configuration Files

Configuration is stored in ~/.openrouter-cli/:

Main Configuration (config.json)

{
  "apiKey": "your-api-key",
  "defaultProfile": "default",
  "profiles": {
    "default": {
      "name": "default",
      "models": ["claude-3-haiku-20240307", "gpt-3.5-turbo"],
      "temperature": 0.7,
      "maxTokens": 1000
    }
  }
}

Templates (templates.json)

[
  {
    "name": "code-review",
    "system": "You are an expert code reviewer.",
    "prompt": "Review the following code: {prompt}",
    "models": ["gpt-4-turbo"],
    "temperature": 0.3,
    "maxTokens": 2000,
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:00:00.000Z"
  }
]

Environment Variables

You can also set configuration via environment variables:

export OPENROUTER_API_KEY=your-api-key

Requirements

  • Node.js >= 22.0.0
  • npm or yarn

Development

# Clone the repository
git clone https://github.com/ikarza/openrouter-cli.git
cd openrouter-cli

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build for production
npm run build

# Run compiled version
npm start

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues, questions, or suggestions, please open an issue on GitHub.