Skip to main content
OpenRouter provides access to multiple AI providers through a single API, giving you flexibility to switch between models like GPT-4, Claude, Gemini, and others.

Features

  • Unified API: Access multiple AI providers with one API key
  • Model Flexibility: Switch between models without code changes
  • Competitive Pricing: Pay-per-use with transparent pricing
  • No Rate Limits: Less restrictive than individual provider limits

Setup

1

Get API Key

Visit OpenRouter and sign up for an account.
  1. Navigate to Keys section
  2. Create a new API key
  3. Copy the key (starts with sk-or-v1-)
2

Configure Environment

Add your OpenRouter settings to .env:
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=google/gemini-2.5-flash
Keep your API key secure. Never commit it to version control.
3

Enable OpenRouter in Code

OpenRouter is enabled when you pass the useOpenRouter parameter:
const llmHelper = new LLMHelper(
  undefined,           // apiKey (not needed)
  false,              // useOllama
  undefined,          // ollamaModel
  undefined,          // ollamaUrl
  true,               // useOpenRouter ✓
  process.env.OPENROUTER_API_KEY,
  process.env.OPENROUTER_MODEL
)
4

Verify Configuration

Start Cluely and check for:
[LLMHelper] Using OpenRouter with model: google/gemini-2.5-flash

Configuration

Environment Variables

VariableRequiredDescriptionDefault
OPENROUTER_API_KEYYesYour OpenRouter API key-
OPENROUTER_MODELNoModel to usegoogle/gemini-2.5-flash

Supported Models

Cluely is tested with these models, but OpenRouter supports many more:
OPENROUTER_MODEL=google/gemini-2.5-flash
OPENROUTER_MODEL=google/gemini-pro
OPENROUTER_MODEL=google/gemini-pro-vision
Pros: Fast, high-quality, vision support on some models Pricing: Low cost per token
See the full list of models at OpenRouter Models

API Implementation

Request Configuration

Cluely sends requests to OpenRouter with this configuration:
// OpenRouter API call (source/electron/LLMHelper.ts:242-261)
const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${this.openRouterApiKey}`,
    'Content-Type': 'application/json',
    'HTTP-Referer': 'https://cluely.ai',
    'X-Title': 'Cluely'
  },
  body: JSON.stringify({
    model: this.openRouterModel,
    messages: [
      {
        role: "user",
        content: prompt
      }
    ],
    temperature: 0.7,
    max_tokens: 4096
  }),
})

Endpoint

POST https://openrouter.ai/api/v1/chat/completions

Headers

HeaderValuePurpose
AuthorizationBearer {API_KEY}Authentication
Content-Typeapplication/jsonRequest format
HTTP-Refererhttps://cluely.aiApp identification
X-TitleCluelyApp name

Model Selection

Default Model

Cluely uses google/gemini-2.5-flash as the default OpenRouter model:
// Default OpenRouter model (source/electron/LLMHelper.ts:33)
private openRouterModel: string = "google/gemini-2.5-flash"

Changing Models

OPENROUTER_MODEL=anthropic/claude-3-opus

Limitations with OpenRouter

OpenRouter has some limitations in Cluely’s current implementation:

Vision/Image Analysis

OpenRouter cannot directly analyze images in the current implementation:
// Guidance-only approach (source/electron/LLMHelper.ts:381-392)
if (this.useOpenRouter) {
  const imageCount = imagePaths.length;
  const prompt = `I have ${imageCount} screenshot(s) that I need help analyzing...`
  // Provides guidance instead of actual image analysis
}
Workaround: Switch to Gemini for screenshot analysis features.

Audio Processing

Audio features are not supported with OpenRouter. Cluely uses Gemini for all voice functionality.

Switching to OpenRouter

At Runtime

Switch from another provider to OpenRouter:
// Switch to OpenRouter
await llmHelper.switchToOpenRouter(
  'sk-or-v1-your_api_key',
  'google/gemini-2.5-flash'
)

// Verify current provider
const provider = llmHelper.getCurrentProvider()
console.log(provider)  // "openrouter"

const model = llmHelper.getCurrentModel()
console.log(model)  // "google/gemini-2.5-flash"

Check Connection

Test your OpenRouter configuration:
const result = await llmHelper.testConnection()

if (result.success) {
  console.log('OpenRouter connected successfully')
} else {
  console.error('Connection failed:', result.error)
}

Cost Management

Monitor Usage

Track your OpenRouter usage:
  1. Visit OpenRouter Dashboard
  2. View usage by model and date
  3. Set spending limits to prevent overages

Cost Optimization

  • For simple tasks: Use google/gemini-2.5-flash or openai/gpt-3.5-turbo
  • For complex reasoning: Use openai/gpt-4 or anthropic/claude-3-opus
  • For cost efficiency: Use open-source models like meta-llama/llama-3-70b
// Reduce max_tokens for shorter responses
max_tokens: 2048  // instead of 4096

// Lower temperature for more focused responses
temperature: 0.5  // instead of 0.7
Implement client-side rate limiting to control costs:
  • Limit requests per minute
  • Cache common responses
  • Debounce user input

Troubleshooting

Error: OpenRouter API key is not configuredSolutions:
  1. Verify OPENROUTER_API_KEY is set in .env
  2. Check API key starts with sk-or-v1-
  3. Ensure no extra spaces or quotes in .env
  4. Restart Cluely after updating .env
Error: Model not found or similarSolutions:
  1. Check model name is correct (case-sensitive)
  2. Verify model exists: OpenRouter Models
  3. Use full model path: google/gemini-2.5-flash not just gemini-2.5-flash
Error: 429 Too Many RequestsSolutions:
  1. Wait before retrying (OpenRouter handles rate limits per model)
  2. Switch to a different model with higher limits
  3. Upgrade your OpenRouter plan
Error: Payment or credit errorsSolutions:
  1. Add credits in OpenRouter dashboard
  2. Update payment method
  3. Check spending limits aren’t exceeded

Best Practices

  1. Start with default model: google/gemini-2.5-flash offers good balance of cost and quality
  2. Monitor usage: Check OpenRouter dashboard regularly
  3. Test before production: Verify model behavior matches expectations
  4. Set spending limits: Prevent unexpected charges
  5. Use appropriate models: Don’t use expensive models for simple tasks

Hybrid Setup

Combine OpenRouter with other providers:
// Use OpenRouter for text chat
const llmHelper = new LLMHelper(
  process.env.GEMINI_API_KEY,      // Still needed for voice
  false,
  undefined,
  undefined,
  true,                             // Enable OpenRouter
  process.env.OPENROUTER_API_KEY,
  'anthropic/claude-3-opus'
)

// Gemini handles voice automatically
// OpenRouter handles text chat

Next Steps

Model Comparison

Compare different AI models and providers

K2 Think Setup

Configure advanced reasoning AI

Build docs developers (and LLMs) love