From e77c071bb8d938e5cb8a3fe305cd30b838dbcf4e Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Thu, 18 Sep 2025 18:21:59 +0300 Subject: [PATCH] Update fallback_models.md --- docs/swarms/utils/fallback_models.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/swarms/utils/fallback_models.md b/docs/swarms/utils/fallback_models.md index 90b2d3cc..6973ff49 100644 --- a/docs/swarms/utils/fallback_models.md +++ b/docs/swarms/utils/fallback_models.md @@ -31,10 +31,9 @@ agent = Agent( ```python from swarms import Agent -# Configure multiple fallback models +# Configure multiple fallback models using unified list agent = Agent( - model_name="gpt-4o", # Primary model - fallback_models=["gpt-4o-mini", "gpt-3.5-turbo", "claude-3-haiku"], # Fallback models in order + fallback_models=["gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo", "claude-3-haiku"], # First is primary, rest are fallbacks max_loops=1 ) ``` @@ -46,11 +45,17 @@ from swarms import Agent # You can use both single fallback and fallback list agent = Agent( - model_name="gpt-4o", + model_name="gpt-4o", # Primary model fallback_model_name="gpt-4o-mini", # Single fallback fallback_models=["gpt-3.5-turbo", "claude-3-haiku"], # Additional fallbacks max_loops=1 ) + +# Or use the unified list approach (recommended) +agent = Agent( + fallback_models=["gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo", "claude-3-haiku"], + max_loops=1 +) # Final order: gpt-4o -> gpt-4o-mini -> gpt-3.5-turbo -> claude-3-haiku ``` @@ -272,3 +277,5 @@ The fallback system is fully backward compatible. Existing agents will continue ## Conclusion The fallback model system provides a robust way to ensure your Swarms agents remain operational even when individual models fail. By configuring appropriate fallback models, you can improve reliability, handle rate limits, and optimize costs while maintaining the same simple API. + +For more examples and advanced usage, see the `examples/fallback_model_example.py` file in the Swarms repository.