Skip to main content

🔀 llm-failover-router

Resilient Multi-Provider LLM Fallback Router for High-Availability AI Applications.

PyPI License: MIT


📌 Why llm-failover-router?

When LLM APIs experience outages, rate-limits (HTTP 429), or network timeouts, your application crashes or hangs.

llm-failover-router provides a zero-overhead, multi-provider fallback strategy: If Provider A (e.g., DeepSeek) fails or times out, it seamlessly switches to Provider B (OpenAI) or Provider C (Local Ollama) in milliseconds!


⚡ Quick Start

pip install llm-failover-router

Usage Example:

from llm_failover_router import LLMRouter, ProviderConfig

# Configure providers with priority order
router = LLMRouter(
    providers=[
        ProviderConfig(name="deepseek", api_key="sk-...", model="deepseek-chat"),
        ProviderConfig(name="openai", api_key="sk-...", model="gpt-4o-mini"),
        ProviderConfig(name="ollama", endpoint="http://localhost:11434", model="llama3"),
    ],
    timeout_seconds=5.0
)

# Executes primary provider; automatically falls back if API fails!
response = router.generate("Explain quantum computing in simple terms.")
print(f"Provider Used: {response.provider_used}")
print(f"Content: {response.content}")

👤 Author

Mohamed Shaban (محمد شعبان العتماني) — Applied AI Engineer
🌐 Website: msalatmani.org | 📧 Email: msalatmani@gmail.com

Download files

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

Source Distribution

llm_failover_router-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

llm_failover_router-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_failover_router-0.1.0.tar.gz.

File metadata

  • Download URL: llm_failover_router-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for llm_failover_router-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aff96fe03bd8179816448f1e435bcd1ff7425d2e4335af0e7ed86f8732400b70
MD5 1948143486eb3124f8a30bcdb0da9d5b
BLAKE2b-256 34db456ea95c3e0868b279a6074cf574b801ac241a5e3a401da8be5cf6fd51d7

See more details on using hashes here.

File details

Details for the file llm_failover_router-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_failover_router-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3686c85e6b5a5e46298063c09892d1f8cdc86486738fbadacb52c0e1cfe5905a
MD5 2fcd810e8b2a3e3412dac363dcaabfce
BLAKE2b-256 6f62fca277b27193d5ee6fb28f652e78aec2eb6358f4508e144c7c207ef67e94

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 Sentry Error logging StatusPage Status page