Skip to main content
Use OpenRouter’s Chat API to send messages to multiple models in parallel. This allows you to use the best model for the task at hand, and to handle errors and timeouts gracefully. For details, see examples in cookbook/90_models/openrouter/chat.
ExampleDescription
BasicCookbook example for openrouter/chat/basic.py.
Dynamic Model RouterDynamic models provide automatic failover when the primary model encounters rate limits, timeouts, unavailability or model overload.
RetryExample demonstrating how to set up retries with OpenRouter.
Structured OutputCookbook example for openrouter/chat/structured_output.py.
Tool UseOpenRouter model example.