Skip to content

An IntelliJ IDEA plugin for integrating with OpenRouter.ai, providing access to 400+ AI models with usage monitoring and quota tracking.

License

Notifications You must be signed in to change notification settings

DimazzzZ/openrouter-intellij-plugin

Repository files navigation

OpenRouter IntelliJ Plugin

JetBrains Plugin Version License: MIT

An IntelliJ IDEA plugin for integrating with OpenRouter.ai, providing access to 400+ AI models with usage monitoring, quota tracking, and seamless JetBrains AI Assistant integration.

Features

  • πŸ€– AI Assistant Proxy - Configurable local proxy server (ports 8880-8899 by default) with auto-start control and flexible port selection
  • πŸ“Š Status Bar Widget - Real-time usage display with comprehensive popup menu
  • πŸ”‘ Flexible Authentication - OAuth/PKCE or Provisioning Key support with secure credential storage
  • πŸ“ˆ Usage Analytics - Track token consumption, costs, and model performance
  • πŸ”΄ Real-time Monitoring - Live connection status with color-coded indicators
  • πŸ“‹ Statistics Popup - Detailed usage analytics in modal dialog
  • βš™οΈ Settings Panel - Configuration with validation and testing
  • 🌐 OpenAI Compatibility - Full OpenAI API compatibility layer for custom integrations
  • πŸ”’ Security - Encrypted API key storage with localhost-only proxy access
  • πŸ§ͺ Comprehensive Testing - 475+ tests covering unit, integration, and E2E scenarios
  • πŸ› οΈ Developer-Friendly - Extensive documentation and debugging capabilities
  • ⭐ Favorite Models - Quick access to your preferred AI models with advanced filtering:
    • Filter by provider (OpenAI, Anthropic, Google, Meta, etc.)
    • Filter by capabilities (Vision, Audio, Tools, Image Generation)
    • Filter by context length (< 32K, 32K-128K, > 128K)
    • Quick presets (Popular, Coding, Multimodal, Cost-Effective)
    • Real-time search across 400+ models
  • πŸš€ First-Run Experience - Welcome notification and setup wizard for easy onboarding
  • πŸ’‘ Contextual Help - GotIt tooltips guide you through key features
  • 🎨 Code Quality - Maintained with detekt static analysis and comprehensive refactoring

Installation

From Plugin Marketplace

  1. Open IntelliJ IDEA β†’ Settings β†’ Plugins
  2. Search for "OpenRouter" in Marketplace
  3. Click Install and restart IDE

Manual Installation

  1. Download the latest release from GitHub
  2. Settings β†’ Plugins β†’ βš™οΈ β†’ Install Plugin from Disk...
  3. Select the downloaded ZIP file

Setup

First-Time Setup (Recommended)

When you first install the plugin, a welcome notification will appear with a "Quick Setup" button. This launches a step-by-step wizard that guides you through:

  1. Welcome - Introduction to OpenRouter and what you'll need
  2. Authentication - Choose your authentication method:
    • Regular API Key - OAuth/PKCE flow (one-click browser authorization)
    • Provisioning Key - Extended mode with full monitoring capabilities
  3. Favorite Models - Select your preferred models with embedded search and filtering
  4. Completion - Copy proxy server URL and configure AI Assistant

The wizard makes setup quick and easy, especially for first-time users!

Manual Setup

  1. Open Settings: Settings β†’ Tools β†’ OpenRouter
  2. Choose Authentication Method:
    • Regular API Key: Click "Connect to OpenRouter" for OAuth/PKCE browser authorization
    • Provisioning Key: Get from OpenRouter Provisioning Keys and paste
  3. Select Models: Settings β†’ Tools β†’ OpenRouter β†’ Favorite Models β†’ Choose your models
  4. Start Using: Click status bar widget to access features

πŸ€– AI Assistant Integration

NEW: Connect JetBrains AI Assistant to OpenRouter's 400+ AI models using the plugin's local proxy server!

Quick Start

  1. Configure OpenRouter Plugin (as above)
  2. Configure Proxy Server: Auto-start is disabled by default - manually start via Settings or enable auto-start
  3. Configure AI Assistant: Settings β†’ Tools β†’ AI Assistant β†’ Models β†’ Add custom model
    • Provider: Custom
    • Server URL: Copy from OpenRouter settings (e.g., http://127.0.0.1:8880)
    • API Key: Any text (not validated by proxy)
    • Model: Choose from OpenRouter's model catalog
  4. Start Using: Access 400+ models through AI Assistant

πŸ“– Complete Setup Guide - Step-by-step instructions with screenshot placeholders

Supported Models

  • OpenAI: GPT-4o, GPT-4 Turbo, o1, o3-mini
  • Anthropic: Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku
  • Meta: Llama 3.3, Llama 3.1, Code Llama
  • Google: Gemini 2.0 Flash, Gemini 1.5 Pro
  • Mistral: Mistral Large, Mixtral 8x22B
  • DeepSeek: DeepSeek V3, DeepSeek R1
  • And 390+ more models from 40+ providers!

Benefits

  • βœ… Unified Interface - Use AI Assistant's familiar chat interface
  • βœ… Cost Control - Transparent pricing and real-time usage monitoring
  • βœ… Model Switching - Easy switching between different AI providers
  • βœ… Local Proxy - Secure localhost-only communication
  • βœ… No Limits - Access models beyond AI Assistant's default options

Usage

Status Bar Widget

  • Click: Open popup menu with plugin features
  • Status Indicators: Color-coded connection status (Ready, Connecting, Error, Not Configured)
  • Usage Display: Current quota usage and cost information

Popup Menu

  • AI Assistant Integration: Start/stop proxy server with status display
  • View Quota Usage: Detailed statistics and analytics
  • Settings: Direct access to plugin configuration
  • Configuration Instructions: Setup guide for AI Assistant integration
  • Documentation: Links to OpenRouter API documentation
  • Logout: Clear stored credentials

Proxy Server Configuration

Access via Settings β†’ Tools β†’ OpenRouter β†’ Proxy Server section:

  • Auto-start: Control whether proxy starts automatically on IDEA launch (disabled by default)
  • Port Selection: Choose specific port or auto-select from configurable range
  • Port Range: Configure port range for auto-selection (default: 8880-8899)
  • Immediate Application: Start Proxy button applies current settings without requiring Apply/OK
  • Conflict Avoidance: Default range avoids common development ports (8080, 8000, etc.)
  • Manual Control: Start/stop proxy server on demand from settings panel

Configuration Options

proxyAutoStart = false           // Auto-start on IDEA launch
proxyPort = 0                   // Specific port (0 = auto-select)  
proxyPortRangeStart = 8880      // Range start for auto-selection
proxyPortRangeEnd = 8899        // Range end for auto-selection

Architecture

Core Components

  • Jetty Proxy Server - Configurable embedded HTTP server (default ports 8880-8899) with flexible port selection and auto-start control
  • OpenRouter API Client - Handles authentication, quota tracking, and model access
  • Settings Management - Encrypted credential storage with validation
  • Status Bar Integration - Real-time monitoring with minimal UI footprint

Authentication Methods

The plugin supports two authentication methods:

  • Regular API Key (OAuth/PKCE) - One-click browser authorization, minimal permissions, no usage monitoring
  • Provisioning Key (Extended) - Full functionality with quota tracking, usage monitoring, and API key management
  • Security - All keys encrypted using IntelliJ's credential store
  • Validation - Real-time key testing and status verification

Compatibility

Supported IDEs: IntelliJ IDEA, WebStorm, PyCharm, PhpStorm, RubyMine, CLion, Android Studio, GoLand, Rider IDE Versions: 2024.1+ to 2025.3+ Requirements: OpenRouter.ai account (free or paid)

Development

See DEVELOPMENT.md for development setup and contribution guidelines.

Building

git clone https://github.com/DimazzzZ/openrouter-intellij-plugin.git
cd openrouter-intellij-plugin
./gradlew build

Testing

# Run all tests (475+ tests)
./gradlew test

# Run core functionality tests only
./gradlew test --tests "*ChatCompletionServletTest*" --tests "*FavoriteModelsServiceTest*"

# Run with development IDE for manual testing
./gradlew runIde --no-daemon

Testing Dynamic Plugin Support

The plugin supports installation, updates, and uninstallation without IDE restart (dynamic plugin).

Quick Test (Enable/Disable):

# Start development IDE and test enable/disable
./scripts/test-enable-disable.sh

# In the IDE: Settings β†’ Plugins β†’ Toggle OpenRouter OFF/ON
# Should work without restart βœ…

Full Test (Multiple Versions):

# Build 3 test versions (0.4.0, 0.4.1, 0.4.2)
./scripts/build-test-versions.sh

# Install v0.4.0 (may require restart on first install)
# Update to v0.4.1 (should NOT require restart)
# Update to v0.4.2 (should NOT require restart)

See LOCAL_DYNAMIC_PLUGIN_TESTING.md for detailed testing instructions.

Test Coverage: 475+ tests with 100% pass rate

  • Unit tests for data models, settings, and business logic
  • Integration tests for API key handling and proxy server functionality
  • Authentication tests with MockWebServer for realistic HTTP testing
  • Security tests for API key handling and encryption

For detailed testing information, see TESTING.md.

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.


This is an unofficial plugin and is not affiliated with OpenRouter.ai.

About

An IntelliJ IDEA plugin for integrating with OpenRouter.ai, providing access to 400+ AI models with usage monitoring and quota tracking.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published