Skip to main content
This feature is under active development and more default routers will be available in future releases.
A ready-to-run example is available here!

Using the built-in MultimodalRouter

Define the built-in rule-based MultimodalRouter that will route text-only requests to a secondary LLM and multimodal requests (with images) to the primary, multimodal-capable LLM:
You may define your own router by extending the Router class. See the base class for details.

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/19_llm_routing.py
Automatically route requests to different LLMs based on task characteristics to optimize cost and performance:
examples/01_standalone_sdk/19_llm_routing.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps