A BrainDrive plugin that allows users to configure their OpenRouter API key for accessing various AI models from multiple providers.
OpenRouter is a unified API that provides access to hundreds of AI models from various providers including OpenAI, Anthropic, Google, Meta, and many others. With a single API key, you can access models like GPT-4, Claude 3.5, Gemini Pro, and more.
- π Secure API Key Management: Store your OpenRouter API key securely with encryption
- β Automatic Validation: Validates API key format before saving
- ποΈ Masked Display: Shows only masked version of stored keys for security
- ποΈ Easy Removal: Remove API keys with confirmation dialog
- π User Scoped: Each user has their own isolated API key storage
- π¨ Theme Support: Automatically adapts to light/dark themes
- π± Responsive Design: Works on desktop and mobile devices
With OpenRouter, you can access models from:
- OpenAI: GPT-4, GPT-4o, GPT-3.5-turbo
- Anthropic: Claude 3.5 Sonnet, Claude 3 Haiku
- Google: Gemini Pro, Gemini Flash
- Meta: Llama 3.1, Code Llama
- And many more from various providers
- Get your OpenRouter API key from OpenRouter Platform
- Ensure you have BrainDrive installed and running
- Navigate to the BrainDrive plugin manager
- Install the "BrainDrive OpenRouter" plugin
- The plugin will be available in your settings
-
Configure API Key:
- Go to Settings β OpenRouter API Keys
- Enter your OpenRouter API key (starts with
sk-or-) - Click "Save API Key"
-
Verify Installation:
- The plugin will show a masked version of your key
- Status will indicate if the key is valid
-
Use in Chat:
- Once configured, OpenRouter models will be available in the chat module
- Select from various providers and models
-
Manage Keys:
- Update your API key anytime
- Remove the key with confirmation dialog
OpenRouter API keys follow this format:
- Start with
sk-or- - Minimum length: 26 characters
- No spaces or special characters
- Encryption: API keys are encrypted before storage
- Masking: Only masked versions are sent to frontend
- Validation: Format validation before saving
- User Isolation: Each user's keys are isolated
- Easy Removal: Quick and secure key removal
# Install dependencies
npm install
# Build for production
npm run build
# Development mode with hot reload
npm startBrainDriveOpenRouter/
βββ src/
β βββ ComponentOpenRouterKeys.tsx # Main component
β βββ ComponentOpenRouterKeys.css # Styles
β βββ types.ts # TypeScript types
β βββ index.tsx # Entry point
β βββ components/ # Reusable components
β βββ services/ # Service integrations
β βββ utils/ # Utility functions
βββ public/
β βββ index.html # Plugin info page
βββ lifecycle_manager.py # Backend lifecycle management
βββ api_endpoints.py # API endpoints
βββ package.json # Dependencies and metadata
βββ webpack.config.js # Build configuration
βββ tsconfig.json # TypeScript configuration
The plugin integrates with BrainDrive's backend through:
- Settings System: Uses BrainDrive's settings framework for API key storage
- Lifecycle Management: Proper install/uninstall/update handling
- API Endpoints: RESTful endpoints for plugin management
- Database Integration: User-scoped plugin and settings storage
The plugin supports the following configuration options:
showAdvancedOptions: Show advanced configuration optionsenableKeyValidation: Enable API key validation on save
-
"API key must start with 'sk-or-'"
- Ensure you're using an OpenRouter API key, not OpenAI
- Get your key from OpenRouter Platform
-
"API key appears to be too short"
- OpenRouter keys should be at least 26 characters
- Check for any accidental truncation
-
Plugin not appearing in Settings
- Ensure the plugin is properly installed
- Check browser console for errors
- Verify user permissions
-
Models not available in chat
- Verify API key is saved and valid
- Check if OpenRouter integration is enabled in chat module
Enable debug logging by setting:
localStorage.setItem("openrouter-debug", "true");- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This plugin is part of BrainDrive and follows the same licensing terms.
For support:
- Check the troubleshooting section above
- Review BrainDrive documentation
- Open an issue in the BrainDrive repository
- Initial release
- OpenRouter API key management
- Secure storage and validation
- Theme support and responsive design