Python SDK
MultiRoute Python SDK
The MultiRoute Python SDK connects your app to MultiRoute's smart LLM/AI router for high-availability and client-side failover. It ensures that your AI-powered workloads remain reliable even when primary providers experience outages.
Core Features
- Unified Routing: Transparently route requests through the MultiRoute smart LLM/AI router.
- Automatic Failover: Built-in detection of router outages with instant, local fallback to primary SDKs.
- Provider Parity: Maintain the same interface as your favorite SDKs (OpenAI, Anthropic, Google GenAI, Pydantic AI).
- Minimal Configuration: Enable routing with just an API key and as few as one line of code change.
How Failover Works
The SDK talks to MultiRoute's smart LLM/AI router:
- Router First: When a request is made, the SDK attempts to route it through the MultiRoute router (
api.multiroute.ai). - Error Detection: The SDK monitors for specific high-availability errors, including connection timeouts, server errors (5xx), and missing endpoints (404).
- Local Fallback: If an error is detected, the SDK immediately retries the request using the native provider's standard endpoint.
- Transparent Experience: This entire process happens locally within the SDK, ensuring the lowest possible latency for failover.
Supported Providers & Integrations
- OpenAI — Wrap
openai-pythonfor failover. - Anthropic — Wrap
anthropic-sdk-pythonfor failover. - Google GenAI — Native Google GenAI integration.
- Pydantic AI — Agentic workflows with built-in failover.
- LiteLLM — High-level abstraction for multiple providers.
Installation
pip install multiroute
Note: You will also need the native provider SDKs installed.