A Hermes Agent provider plugin that integrates with Bitrouter for intelligent model routing and provider management.
This plugin allows Hermes Agent to leverage Bitrouter's sophisticated routing capabilities, including:
- π Intelligent Routing: Auto-cascade through multiple providers based on availability
- π Unified Auth: Bitrouter handles all provider authentication (Bearer, OAuth, etc.)
- π Model Discovery: Automatic sync of available models from Bitrouter config
- π Auto-start: Automatically launches Bitrouter daemon when needed
- π‘ Streaming: Full SSE streaming support with progress events
Hermes Agent β Bitrouter Plugin β Bitrouter Daemon β Provider APIs
β
Routing Logic
Auth Management
Rate Limiting
Fallback Chains
pip install pyyaml httpx psutilEnsure Bitrouter is installed and configured:
# Install Bitrouter (if not already installed)
cargo install bitrouter
# Create basic config
mkdir -p ~/.bitrouter
cp examples/bitrouter-config.yaml ~/.bitrouter/config.yaml# Copy plugin to Hermes plugins directory
mkdir -p ~/.hermes/plugins/model-providers
cp -r hermes_bitrouter ~/.hermes/plugins/model-providers/bitrouter# Set Bitrouter as your provider
hermes config set provider bitrouter
# Test the integration
hermes chat "Hello, world!"BITROUTER_URL: Daemon URL (default:http://localhost:7777)BITROUTER_CONFIG_PATH: Custom config path (optional)
See examples/bitrouter-config.yaml for a complete configuration example.
The plugin automatically detects and starts the Bitrouter daemon:
# Daemon management is handled automatically
provider = BitrouterProvider() # Will start daemon if neededModels are automatically synced from Bitrouter:
# List available models
hermes models list
# Models from Bitrouter config appear automatically
# - gpt-4o (via openai)
# - claude-3-5-sonnet (via anthropic)
# - Virtual models from configFull streaming compatibility with Hermes:
# Streaming works automatically
response = await provider.stream_chat_completion(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
stream=True
)Comprehensive error handling with context:
- Daemon Issues: Auto-retry with restart
- Routing Errors: Clear model availability feedback
- Provider Errors: Surface upstream issues with provider context
python -m pytest tests/ -v# Test daemon connectivity
python -c "from hermes_bitrouter.daemon import BitrouterDaemonManager; dm = BitrouterDaemonManager(); print('Running:', dm.is_running())"
# Test model discovery
python -c "from hermes_bitrouter.config import BitrouterConfigReader; cr = BitrouterConfigReader(); print('Models:', [m.id for m in cr.get_all_models()])"- Daemon won't start: Check that
bitrouterbinary is in PATH - No models found: Verify Bitrouter config has providers configured
- Auth errors: Check provider credentials in Bitrouter config
- Connection refused: Ensure daemon is running on correct port
# Enable debug logging
export HERMES_LOG_LEVEL=debug
hermes chat "test message"GitHub: https://github.com/bitrouter/hermes-bitrouter-plugin
git clone https://github.com/bitrouter/hermes-bitrouter-plugin.git
cd hermes-bitrouter-plugin
pip install -r requirements.txt
python3 scripts/setup.pyexport OPENROUTER_API_KEY="your-api-key-here"
python3 test_live.py- Fork this repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE for details.