OpenRouter

Connect hi-shell to OpenRouter for access to dozens of LLM models through a single API key. OpenRouter provides a unified interface to models from OpenAI, Anthropic, Google, Meta, and more.

Prerequisites

Setup

1. Get an API Key

  1. Sign up at openrouter.ai
  2. Go to Keys
  3. Create a new API key
  4. Copy the key (starts with sk-or-)

2. Configure hi-shell

hi-shell --init
# Select "Cloud" → "OpenRouter"
# Paste your API key
# Choose a model (e.g., "microsoft/phi-3-mini-4k-instruct")

Manual Configuration

Edit ~/.config/hi-shell/config.toml:

llm_provider = "Cloud"
cloud_provider = "OpenRouter"
cloud_model = "microsoft/phi-3-mini-4k-instruct"
api_key = "sk-or-your-api-key-here"

Recommended Models

ModelCostQualitySpeedBest For
microsoft/phi-3-mini-4k-instructFreeGoodFastDefault, good balance
meta-llama/llama-3.2-3b-instructFreeGoodFastGeneral use
google/gemini-2.0-flash-expFreeGoodVery fastQuick commands
anthropic/claude-3.5-sonnetPaidExcellentMediumComplex tasks
openai/gpt-4oPaidExcellentMediumHigh quality

Many models on OpenRouter are free to use. Check openrouter.ai/models for pricing.

Configuration Options

OptionDescription
cloud_modelModel identifier (e.g., microsoft/phi-3-mini-4k-instruct)
api_keyYour OpenRouter API key

Security Note

Your API key is stored locally in the config file. Keep it secure:

# Set restrictive permissions on your config
chmod 600 ~/.config/hi-shell/config.toml

Troubleshooting

“Invalid API key” Error

  • Verify your key at openrouter.ai/keys
  • Make sure the key starts with sk-or-
  • Check for extra whitespace when pasting

Rate Limiting

Free models have rate limits. If you hit them:

  • Wait a moment and try again
  • Switch to a paid model for higher limits
  • Use a local provider instead

Model Not Available

Some models may be temporarily unavailable. Try:

  • A different model
  • Checking the model status at openrouter.ai