Features

  • Multiple providers - Access 50+ models from various providers
  • Automatic failover - Route to available providers
  • Cost optimization - Choose models by price/performance
  • Single API key - One key for all providers

Installation

elizaos plugins add @elizaos/plugin-openrouter

Configuration

Environment Variables

# Required
OPENROUTER_API_KEY=sk-or-...

# Optional model configuration
# You can use any model available on OpenRouter
OPENROUTER_SMALL_MODEL=google/gemini-2.0-flash-001           # Default: google/gemini-2.0-flash-001
OPENROUTER_LARGE_MODEL=google/gemini-2.5-flash-preview-05-20 # Default: google/gemini-2.5-flash-preview-05-20
OPENROUTER_IMAGE_MODEL=anthropic/claude-3-5-sonnet           # For vision tasks

# Examples of other available models:
# OPENROUTER_SMALL_MODEL=anthropic/claude-3-haiku
# OPENROUTER_LARGE_MODEL=anthropic/claude-3-opus
# OPENROUTER_LARGE_MODEL=openai/gpt-4o
# OPENROUTER_SMALL_MODEL=meta-llama/llama-3.1-8b-instruct:free

Character Configuration

{
  "name": "MyAgent",
  "plugins": [
    "@elizaos/plugin-openrouter",
    "@elizaos/plugin-ollama"  // For embeddings
  ]
}

Supported Operations

OperationSupportNotes
TEXT_GENERATIONAll available models
EMBEDDINGUse fallback plugin
OBJECT_GENERATIONModel dependent

Important: Embedding Fallback

OpenRouter doesn’t provide embedding endpoints, so include a fallback:

{
  "plugins": [
    "@elizaos/plugin-openrouter",  // Text generation
    "@elizaos/plugin-openai"        // Embeddings
  ]
}

Model Configuration

The plugin uses model tiers:

  • SMALL_MODEL: Fast, cost-effective responses
  • LARGE_MODEL: Complex reasoning, best quality
  • IMAGE_MODEL: Multimodal capabilities

OpenRouter provides access to 50+ models from various providers. You can use:

Premium Models

  • Any Anthropic Claude model (Opus, Sonnet, Haiku)
  • Any OpenAI GPT model (GPT-4o, GPT-4, GPT-3.5)
  • Google Gemini models (Pro, Flash, etc.)
  • Cohere Command models

Open Models

  • Meta Llama models (3.1, 3.2, 3.3)
  • Mistral/Mixtral models
  • Many models with :free suffix for testing

Pricing Strategy

OpenRouter charges a small markup (usually ~10%) on top of provider prices:

  1. Pay-per-token - No monthly fees
  2. Price transparency - See costs per model
  3. Credits system - Pre-pay for usage

Advanced Features

Model Routing

{
  "settings": {
    "openrouter": {
      "route": "fallback",  // or "random"
      "models": [
        "anthropic/claude-3-opus",
        "openai/gpt-4"
      ]
    }
  }
}

Provider Preferences

Prefer certain providers:

{
  "settings": {
    "openrouter": {
      "providers": {
        "anthropic": 1.0,
        "openai": 0.8,
        "google": 0.6
      }
    }
  }
}

External Resources