Skip to main content

A free multi-source GenAI orchestration library for automatic model selection and routing

Project description

OpenMux

Free Multi-Source GenAI Orchestration Library

OpenMux is a Python library that automatically selects, routes, and combines outputs from free GenAI models and API providers. It creates a unified interface for discovering, connecting, and using open-access models across the AI ecosystem โ€” including OpenRouter, HuggingFace, Together AI, Mistral, Ollama, LM Studio, and other publicly available sources.

Python Version License Code Coverage


๐Ÿš€ Quick Start

from openmux import Orchestrator, TaskType

# Initialize
orchestrator = Orchestrator()

# Process a query
response = orchestrator.process("What is Python?")
print(response)

# Process with specific task type
code_response = orchestrator.process(
    "Write a fibonacci function",
    task_type=TaskType.CODE
)

# Multi-model processing
combined = orchestrator.process_multi(
    query="Explain quantum computing",
    num_models=2,
    combination_method="summarize"
)

๐ŸŒŸ Features

  • ๐Ÿ” Automatic Provider Discovery

    • Maintains updated list of free GenAI model providers
    • Automatic metadata updates from central registry
    • Focus on free and open-source endpoints
  • ๐ŸŽฏ Task Auto-Classification

    • Intelligent query analysis for task classification
    • Supports: chat, code, TTS, audio, embeddings, image
    • Lightweight local classifier with manual override options
  • โšก Smart Model Selection

    • Automatic model selection based on capability metadata
    • Response quality tracking
    • Latency and uptime monitoring
    • Transparent selection reasoning
  • ๐Ÿ”€ Multi-Model Routing

    • Parallel query processing across multiple models
    • Configurable response combination methods
    • Support for text and embeddings (multimodal planned)
  • ๐Ÿ’พ Offline & Local Fallback

    • Local model hosting support via Ollama, LM Studio
    • Bundled lightweight open models
    • Hardware-aware automatic mode switching
    • Configurable fallback settings

๐Ÿ“ Project Structure

openmux/
โ”œโ”€โ”€ core/               # Core orchestration
โ”‚   โ”œโ”€โ”€ orchestrator.py # Main orchestrator
โ”‚   โ”œโ”€โ”€ selector.py     # Model selection logic
โ”‚   โ”œโ”€โ”€ router.py       # Query routing
โ”‚   โ”œโ”€โ”€ combiner.py     # Response combination
โ”‚   โ””โ”€โ”€ fallback.py     # Fallback handling
โ”œโ”€โ”€ providers/          # Provider implementations
โ”‚   โ”œโ”€โ”€ base.py         # Base provider interface
โ”‚   โ”œโ”€โ”€ openrouter.py   # OpenRouter integration
โ”‚   โ”œโ”€โ”€ huggingface.py  # HuggingFace integration
โ”‚   โ”œโ”€โ”€ ollama.py       # Ollama integration
โ”‚   โ””โ”€โ”€ registry.py     # Provider registry
โ”œโ”€โ”€ classifier/         # Task classification
โ”‚   โ”œโ”€โ”€ classifier.py   # Main classifier
โ”‚   โ””โ”€โ”€ task_types.py   # Task type definitions
โ”œโ”€โ”€ cli/                # Command-line interface
โ”‚   โ””โ”€โ”€ main.py         # CLI implementation
โ””โ”€โ”€ utils/              # Utility functions
    โ”œโ”€โ”€ config.py       # Configuration management
    โ””โ”€โ”€ logging.py      # Logging utilities

๐Ÿ“ฆ Installation

From TestPyPI (Current)

# Using pip
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ openmux

# Using uv (recommended)
UV_HTTP_TIMEOUT=300 uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ openmux

From PyPI (Coming Soon)

pip install openmux
# or using uv
uv pip install openmux

From Source

# Clone the repository
git clone https://github.com/mdnu838/OpenMux.git
cd OpenMux

# Create virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
uv pip install -e ".[dev]"

Environment Setup

  1. Copy the example environment file:

    cp .env.example .env
    
  2. Add your API keys to .env:

    # OpenRouter (required for online models)
    OPENROUTER_API_KEY=your_key_here
    
    # HuggingFace (optional)
    HF_TOKEN=your_token_here
    
    # Ollama (for local models)
    OLLAMA_URL=http://localhost:11434
    
  3. Never commit your .env file! It's already in .gitignore.


๐Ÿงช Testing

# Run all tests
pytest tests/ -v

# Run unit tests only
pytest tests/unit/ -v

# Run with coverage
pytest tests/ --cov=openmux --cov-report=term-missing

# Run mock-based tests (no API keys needed)
pytest tests/unit/ tests/integration/test_orchestrator_mock.py -v

Test Status: 12/12 core tests passing (100% success rate)


๐Ÿค Contributing

We welcome contributions! All feature changes require a branch and Pull Request.

Quick Contribution Guide

  1. Fork and clone the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes following our code style
  4. Add tests for new functionality
  5. Run tests: pytest tests/ -v
  6. Format code: black openmux/ tests/
  7. Create Pull Request to main branch

See CONTRIBUTING.md for detailed guidelines.

Branching Strategy

  • main - Production-ready code (protected)
  • mvp-alpha - Alpha testing branch (protected)
  • feature/* - New features
  • bugfix/* - Bug fixes
  • docs/* - Documentation updates

All PRs require:

  • โœ… Passing CI/CD checks
  • โœ… Code review approval
  • โœ… โ‰ฅ90% test coverage
  • โœ… Updated documentation

๐Ÿ“– Documentation


๐Ÿ”’ Security

  • Never commit API keys or secrets to the repository
  • Use .env file for sensitive data (already in .gitignore)
  • Report security issues via GitHub Issues or contact maintainers

See SECURITY.md for more details.


๐Ÿ“Š Project Status

Current Version: 0.1.0
Status: Alpha - Published to TestPyPI
Test Coverage: 100% (core components)

Recent Updates

  • โœ… Published to TestPyPI
  • โœ… Fixed packaging to include all subpackages
  • โœ… Complete orchestration engine
  • โœ… Mock-based integration tests
  • โœ… Classifier fully functional
  • โœ… GitHub Actions CI/CD workflows
  • โœ… Comprehensive documentation

See CHANGELOG.md for detailed version history.


๐Ÿ› ๏ธ Development

Quick Setup

# Clone the repository
git clone https://github.com/mdnu838/OpenMux.git
cd OpenMux

# Set up the development environment
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

# Run tests
pytest tests/ -v

Workflow

  1. All feature changes require a separate branch
  2. Create PR to main for review
  3. CI/CD automatically runs tests
  4. Merge to main triggers PyPI publish

See CONTRIBUTING.md for detailed guidelines.

License

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


๐Ÿ™ Acknowledgments

Built with:

  • uv - Fast Python package manager
  • pytest - Testing framework
  • aiohttp - Async HTTP client
  • pydantic - Data validation
  • rich - Beautiful terminal output

Star โญ this repo if you find it useful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmux-0.1.11.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmux-0.1.11-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file openmux-0.1.11.tar.gz.

File metadata

  • Download URL: openmux-0.1.11.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for openmux-0.1.11.tar.gz
Algorithm Hash digest
SHA256 b288fb077a5ba655f17faa7c4afbc3834a15d70d9779cefae662fdcc1f535de3
MD5 d4f431dc8c79a678511d40df9d9638fa
BLAKE2b-256 e81c8f0a6b20b62cec5ffd68d9d88c96fcca5ab02c4f9d4cf86fe21afaa02099

See more details on using hashes here.

File details

Details for the file openmux-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: openmux-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 49.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for openmux-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 43bdca243c4c35c118e64c73a7a2eee89677d8002d618e8b304a5a06245b3884
MD5 da41ac6f9a3a9a3ecd234f7d7463ac5d
BLAKE2b-256 4ea33544d84ab5511de5ac86430c23cdf633c56681c9062aaedf8bb9fdd3f9d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page