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.5.tar.gz (25.7 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.5-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openmux-0.1.5.tar.gz
  • Upload date:
  • Size: 25.7 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.5.tar.gz
Algorithm Hash digest
SHA256 f4f98579fe8126bc407a4a9c7c1c0a56d3318893d6e9de8decc957937b410e62
MD5 4a1926d8c8c3dd4a8bf0c5e2d07a00b1
BLAKE2b-256 9fd0e4675d6cc9594339738aa62fa8005444b2ff8dd96112939390e717ab4f9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openmux-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 32.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8dcd8484143d4dfb7c0f377332289487bbe095bd36e678e9c7d072f918f9dbdd
MD5 35d2b388262046802958a844fce855ef
BLAKE2b-256 e0152207cd36b9d5c7421454aa3118f3541fc48f64ab8dbcf62c84661047f7f5

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