Skip to content

Latest commit

 

History

History
 
 

README.md

Swarms Examples

This directory contains comprehensive examples demonstrating various capabilities and use cases of the Swarms framework. Each subdirectory focuses on specific aspects of multi-agent systems, single agents, tools, and integrations.

Directory Overview

Multi-Agent Systems

Example Description
multi_agent/ Advanced multi-agent patterns including agent rearrangement, auto swarm builder (ASB), batched workflows, board of directors, caching, concurrent processing, councils, debates, elections, forest swarms, graph workflows, group chats, heavy swarms, hierarchical swarms, LLM council, majority voting, orchestration examples, paper implementations, sequential workflows, social algorithms, simulations, spreadsheet examples, swarm routing, and utilities
README.md Complete multi-agent examples documentation
duo_agent.py Two-agent collaboration example
tree_swarm_new_updates.py Tree swarm implementation with latest updates
agent_rearrange_examples/ Agent rearrangement and reorganization examples
agent_router_examples/ Agent routing and routing patterns
asb/ Auto Swarm Builder (ASB) examples and implementations
batched_grid_workflow/ Batched grid workflow examples
board_of_directors/ Board of directors pattern examples
caching_examples/ Agent caching examples
concurrent_examples/ Concurrent processing and parallel execution examples
council/ Council pattern examples with judge evaluation
council_of_judges/ Council of judges pattern implementations
debate_examples/ Multi-agent debate and discussion examples
election_swarm_examples/ Election and voting swarm examples
exec_utilities/ Execution utilities including uvloop examples
forest_swarm_examples/ Forest swarm and tree-based swarm examples
graphworkflow_examples/ Graph workflow and graph-based processing examples
groupchat/ Group chat and multi-agent conversation examples
heavy_swarm_examples/ Heavy swarm implementations for complex tasks
hiearchical_swarm/ Hierarchical swarm structures and patterns
hscf/ Hierarchical Swarm Control Framework examples
llm_council_examples/ LLM Council collaboration patterns
majority_voting/ Majority voting and consensus examples
mar/ Multi-agent rearrangement examples
moa_examples/ Mixture of Agents (MOA) examples
orchestration_examples/ Agent orchestration and coordination examples
paper_implementations/ Research paper implementations
sequential_workflow/ Sequential workflow examples
simulations/ Multi-agent simulation examples
social_algorithms_examples/ Social algorithm patterns and implementations
spreadsheet_examples/ Spreadsheet-based agent examples
swarm_router/ Swarm routing and routing patterns
swarmarrange/ Swarm arrangement examples
swarms_api_examples/ Swarms API integration examples
utils/ Multi-agent utility functions
agent_grpo_examples/ Agent GRPO (Group Reinforcement Policy Optimization) examples for math and physics problems

Single Agent Systems

Example Description
single_agent/ Single agent implementations including demos, external agent integrations, LLM integrations (Azure, Claude, DeepSeek, Mistral, OpenAI, Qwen), onboarding, RAG, reasoning agents, tools integration, utils, vision capabilities, and MCP integration
README.md Complete single agent examples documentation
simple_agent.py Basic single agent example
auto_agent.py Auto agent implementation
agent_mcp.py MCP integration example
agent_skill_examples/ Agent skill examples including dynamic skills loader, custom skills, and pre-built skills (code review, data visualization, financial analysis)
demos/ Single agent demonstration examples including insurance and legal agents
full_autonomy/ Autonomous agent examples with marketplace integration and full autonomy capabilities
handoffs/ Agent handoff examples including autonomous agents with handoffs
external_agents/ External agent integrations including OpenAI Assistant wrapper
llms/ LLM integration examples for Azure, Claude, DeepSeek, Mistral, OpenAI, O3, and Qwen
azure_agent_api_verison.py Azure agent API version example
azure_agent.py Azure agent example
azure_model_support.py Azure model support
base_llm.py Base LLM example
mistral_example.py Mistral example
o3_agent.py O3 agent example
qwen_3_base.py Qwen 3 base example
claude_examples/ Claude model examples
claude_4_example.py Claude 4 example
claude_4.py Claude 4 implementation
swarms_claude_example.py Swarms Claude example
deepseek_examples/ DeepSeek model examples
deepseek_r1.py DeepSeek R1 example
fast_r1_groq.py Fast R1 Groq example
groq_deepseek_agent.py Groq DeepSeek agent
openai_examples/ OpenAI model examples
4o_mini_demo.py GPT-4o mini demo
reasoning_duo_batched.py Reasoning duo batched example
test_async_litellm.py Async LiteLLM test
onboard/ Agent onboarding examples and configurations
marketplace/ Marketplace prompt integration examples including quant trader agent
rag/ Retrieval Augmented Generation (RAG) implementations with vector database integrations
full_agent_rag_example.py Full agent RAG example
pinecone_example.py Pinecone vector database example
qdrant_agent.py Qdrant agent example
qdrant_rag_example.py Qdrant RAG example
simple_example.py Simple RAG example
reasoning_agent_examples/ Reasoning agent patterns including consistency, GPK, iterative, and reasoning duo
agent_judge_evaluation_criteria_example.py Agent judge evaluation criteria example
agent_judge_example.py Agent judge example
consistency_agent.py Consistency agent
consistency_example.py Consistency example
gpk_agent.py GPK agent
iterative_agent.py Iterative agent
reasoning_agent_router_now.py Reasoning agent router (current)
reasoning_agent_router.py Reasoning agent router
reasoning_duo_example.py Reasoning duo example
reasoning_duo_test.py Reasoning duo test
reasoning_duo.py Reasoning duo implementation
tools/ Tool integration examples including Exa search, LiteLLM, multi-tool usage, Omni modal, Solana, structured outputs, and browser agents
agent_with_exa.py Agent with Exa search integration
exa_search_agent.py Exa search agent example
example_async_vs_multithread.py Async vs multithread example
litellm_tool_example.py LiteLLM tool example
multi_tool_usage_agent.py Multi-tool usage agent
new_tools_examples.py New tools examples
omni_modal_agent.py Omni modal agent
swarms_of_browser_agents.py Swarms of browser agents
swarms_tools_example.py Swarms tools example
together_deepseek_agent.py Together DeepSeek agent
solana_tool/ Solana tool integration
solana_tool.py Solana tool implementation
solana_tool_test.py Solana tool test
structured_outputs/ Structured outputs examples
example_meaning_of_life_agents.py Meaning of life agents example
structured_outputs_example.py Structured outputs example
tools_examples/ Additional tool examples
dex_screener.py DEX screener tool
financial_news_agent.py Financial news agent
simple_tool_example.py Simple tool example
swarms_tool_example_simple.py Simple Swarms tool example
utils/ Single agent utility functions including async agents, custom base URLs, dynamic context windows, fallback tests, handoffs, markdown agents, and XML output
async_agent.py Async agent example
custom_agent_base_url.py Custom agent base URL
dynamic_context_window.py Dynamic context window example
fallback_test.py Fallback test example
grok_4_agent.py Grok 4 agent example
handoffs_example.py Handoffs example
list_agent_output_types.py List agent output types
markdown_agent.py Markdown agent example
medical_agent_add_to_marketplace.py Medical agent marketplace example
xml_output_example.py XML output example
autosaving_examples/ Autosaving examples
autosave_basic_example.py Basic autosave example
autosave_config_access_example.py Autosave config access example
autosave_directory_structure_example.py Autosave directory structure example
autosave_recovery_example.py Autosave recovery example
transform_prompts/ Prompt transformation examples
transforms_agent_example.py Transform agent example
transforms_examples.py Transform examples
vision/ Vision and multimodal agent examples including image processing and batch image examples
anthropic_vision_test.py Anthropic vision test
image_batch_example.py Image batch processing example
multimodal_example.py Multimodal example
multiple_image_processing.py Multiple image processing
vision_test.py Vision test
vision_tools.py Vision tools

Tools & Integrations

Example Description
tools/ Tool integration examples including agent-as-tools, base tool implementations, browser automation, Claude integration, Exa search, Firecrawl, multi-tool usage, and Stagehand integration
README.md Complete tools examples documentation
agent_as_tools.py Using agents as tools
browser_use_as_tool.py Browser automation tool
browser_use_demo.py Browser automation demonstration
claude_as_a_tool.py Claude model integration as a tool
exa_search_agent.py Exa search integration
exa_search_agent_quant.py Exa search with quantitative analysis
exa_search_test.py Exa search testing examples
firecrawl_agents_example.py Firecrawl integration
base_tool_examples/ Base tool implementation examples
base_tool_examples.py Base tool examples
conver_funcs_to_schema.py Convert functions to schema
convert_basemodels.py Convert base models
exa_search_test.py Exa search test
example_usage.py Base tool usage example
schema_validation_example.py Schema validation example
test_anthropic_specific.py Anthropic-specific test
test_base_tool_comprehensive_fixed.py Comprehensive base tool test (fixed)
test_base_tool_comprehensive.py Comprehensive base tool test
test_function_calls_anthropic.py Function calls test (Anthropic)
test_function_calls.py Function calls test
multii_tool_use/ Multi-tool usage examples
stagehand/ Stagehand UI automation
1_stagehand_wrapper_agent.py Stagehand wrapper agent
2_stagehand_tools_agent.py Stagehand tools agent
3_stagehand_mcp_agent.py Stagehand MCP agent
4_stagehand_multi_agent_workflow.py Stagehand multi-agent workflow
tests/ Stagehand tests
test_stagehand_integration.py Stagehand integration test
test_stagehand_simple.py Simple Stagehand test

Model Integrations

Example Description
models/ Various model integrations including Cerebras, GPT-5, GPT-OSS, Llama 4, Lumo, O3, Ollama, and vLLM implementations with concurrent processing examples and provider-specific configurations
README.md Model integration documentation
simple_example_ollama.py Ollama integration example
cerebas_example.py Cerebras model example
lumo_example.py Lumo model example
example_o3.py O3 model example
gpt_5/ GPT-5 model examples
gpt_oss_examples/ GPT-OSS examples
llama4_examples/ Llama 4 examples
main_providers/ Main provider configurations
vllm/ vLLM integration examples

API & Protocols

Swarms API

Example Description
swarms_api/ Swarms API usage examples including agent overview, batch processing, client integration, team examples, analysis, and rate limiting
README.md API examples documentation
agent_overview.py Agent overview and listing examples
client_example.py API client example
batch_example.py Batch processing example
hospital_team.py Hospital management team simulation
legal_team.py Legal team collaboration example
icd_ten_analysis.py ICD-10 medical code analysis
rate_limits.py Rate limiting and throttling examples

Model Context Protocol (MCP)

Example Description
mcp/ Model Context Protocol (MCP) integration examples including agent implementations, multi-connection setups, server configurations, utility functions, and multi-MCP guides
README.md MCP examples documentation
multi_mcp_example.py Multi-MCP connection example
agent_examples/ Agent-based MCP examples
agent_mcp_old.py Legacy agent MCP example
agent_multi_mcp_connections.py Agent with multiple MCP connections
agent_tools_dict_example.py Agent tools dictionary example
mcp_exampler.py MCP example implementation
servers/ MCP server implementations
mcp_agent_tool.py MCP agent tool server
mcp_test.py MCP server testing
okx_crypto_server.py OKX crypto MCP server
test.py MCP server test
mcp_utils/ MCP utility functions
client.py MCP client utility
mcp_client_call.py MCP client call example
mcp_multiple_servers_example.py Multiple MCP servers example
mcp_multiple_tool_test.py Multiple MCP tools test
multiagent_client.py Multi-agent MCP client
singleagent_client.py Single agent MCP client
test_multiple_mcp_servers.py Test multiple MCP servers
utils/ MCP utility subdirectory
find_tools_on_mcp.py Find tools on MCP
mcp_execute_example.py MCP execute example
mcp_load_tools_example.py MCP load tools example
mcp_multiserver_tool_fetch.py Multi-server tool fetch
utils.py MCP utilities
multi_mcp_guide/ Multi-MCP setup guides
agent_mcp.py Agent MCP guide
mcp_agent_tool.py MCP agent tool guide
okx_crypto_server.py OKX crypto server guide

Agents over Protocol (AOP)

Example Description
aop_examples/ Agents over Protocol (AOP) examples demonstrating MCP server setup, agent discovery, client interactions, queue-based task submission, medical AOP implementations, and utility functions
README.md AOP examples documentation
server.py AOP server implementation
client/ AOP client examples and agent discovery including cluster, queue, raw client, and task examples
aop_cluster_example.py AOP cluster example
aop_queue_example.py AOP queue-based task submission
aop_raw_client_code.py Raw AOP client implementation
aop_raw_task_example.py Raw AOP task example
example_new_agent_tools.py New agent tools example
get_all_agents.py Get all available agents
list_agents_and_call_them.py List and call agents example
discovery/ Agent discovery examples including communication and discovery testing
example_agent_communication.py Agent communication example
test_aop_discovery.py AOP discovery testing
simple_discovery_example.py Simple discovery example
example_aop_discovery.py AOP discovery example
medical_aop/ Medical AOP implementations
server.py Medical AOP server
client.py Medical AOP client
utils/ AOP utility functions
network_management_example.py Network management example
comprehensive_aop_example.py Comprehensive AOP example
persistence_management_example.py Persistence management example
network_error_example.py Network error handling example
persistence_example.py Persistence example

Advanced Capabilities

Example Description
reasoning_agents/ Advanced reasoning capabilities including agent judge evaluation systems, O3 model integration, mixture of agents (MOA) sequential examples, and reasoning agent router examples
README.md Reasoning agents documentation
moa_seq_example.py MOA sequential example
agent_judge_examples/ Agent judge evaluation systems
example1_basic_evaluation.py Basic evaluation example
example2_technical_evaluation.py Technical evaluation example
example3_creative_evaluation.py Creative evaluation example
reasoning_agent_router_examples/ Reasoning agent router examples
agent_judge_example.py Agent judge example
gkp_agent_example.py GKP agent example
ire_example.py IRE example
reasoning_duo_example.py Reasoning duo example
reflexion_agent_example.py Reflexion agent example
self_consistency_example.py Self-consistency example
voice_agents/ Voice and speech-enabled agent examples including agent speech, agent with speech, debate with speech, Google Calendar integration, and hierarchical speech swarm capabilities
agent_speech.py Agent with speech capabilities
agent_with_speech.py Speech-enabled agent implementation
debate_with_speech.py Multi-agent debate with speech capabilities
google_calendar_agent.py Google Calendar integration with voice agent
hiearchical_speech_swarm.py Hierarchical speech swarm implementation

Marketplace

Example Description
marketplace/ Swarms marketplace prompt integration examples for using pre-built prompts from the marketplace
zia_agent.py Zia agent implementation using marketplace prompts
single_agent/marketplace/ Single agent marketplace examples including marketplace prompt integration and quant trader agent
marketplace_prompt_example.py Example of using marketplace prompts with agents
quant_trader_agent.py Quantitative trader agent using marketplace prompts

Guides & Tutorials

Example Description
guides/ Comprehensive guides and tutorials including demos, generation length blog, geo guesser agent, graph workflow guide, hackathon examples, hierarchical marketing team, nano banana Jarvis agent, smart database, web scraper agents, workshops, x402 examples, and workshop examples (840_update, 850_workshop)
README.md Guides documentation
hiearchical_marketing_team.py Hierarchical marketing team example
840_update/ Update examples from version 8.4.0 including agent rearrange, auto swarm builder, and fallback examples
850_workshop/ Workshop examples from version 8.5.0 including AOP, MOA, peer review, and concurrent examples
880_update_changelog_examples/ Changelog examples showcasing new features including marketplace integration, multi-agent structures, workflow orchestration, voice agents, evaluation & debate, routing, and autosaving
changelog_890/ Changelog examples from January 2026 release including dynamic skills loader, autonomous agent loop, agent handoffs, API key validation, max loops parameter, multi-tool agent tutorial, hierarchical voice agent, and agent rearrange patterns
mem0/ Mem0 integration examples for memory management with Swarms
demos/ Various demonstration examples including apps, crypto, finance, insurance, legal, medical, real estate, science, and synthetic data
fairy_swarm/ Fairy swarm examples and implementations
generation_length_blog/ Long-form content generation examples
geo_guesser_agent/ Geographic guessing agent examples
graphworkflow_guide/ Comprehensive graph workflow guide and examples
hackathon_judge_agent/ Hackathon judging agent examples
hackathons/ Hackathon project examples
nano_banana_jarvis_agent/ Nano banana Jarvis agent with image generation
smart_database/ Smart database examples
voice_agents/ Voice agent examples with speech capabilities
web_scraper_agents/ Web scraper agent examples
workshops/ Workshop examples
x402_examples/ X402 protocol examples

Deployment

Example Description
deployment/ Deployment strategies and patterns including cron job implementations and FastAPI deployment examples
README.md Deployment documentation
fastapi/ FastAPI deployment examples
cron_job_examples/ Cron job examples

Utilities

Example Description
utils/ Utility functions and helper implementations including agent loader, communication examples, concurrent wrappers, miscellaneous utilities, and telemetry
README.md Utils documentation
agent_loader/ Agent loading utilities
communication_examples/ Agent communication patterns including DuckDB, Pulsar, Redis, and SQLite
fetch_prompt.py Prompt fetching utilities
litellm_connect_issue.py LiteLLM connection issue examples
litellm_network_error_handling.py LiteLLM network error handling
misc/ Miscellaneous utility functions including AOP, conversation, CSV agents, and visualization
agent_map_test.py Agent map test
conversation_simple.py Simple conversation example
conversation_test_truncate.py Conversation truncate test
conversation_test.py Conversation test
csvagent_example.py CSV agent example
dict_to_table.py Dictionary to table conversion
swarm_matcher_example.py Swarm matcher example
test_load_conversation.py Load conversation test
visualizer_test.py Visualizer test
aop/ AOP utility examples
client.py AOP client utility
test_aop.py AOP test
telemetry/ Telemetry and monitoring utilities

User Interface

Example Description
ui/ User interface examples and implementations including chat interfaces
README.md UI examples documentation
chat.py Chat interface example

Command Line Interface

Example Description
cli/ CLI command examples demonstrating all available Swarms CLI features including setup, agent management, multi-agent architectures, and utilities
README.md CLI examples documentation
01_setup_check.sh Environment setup verification
02_onboarding.sh User onboarding process
03_get_api_key.sh API key retrieval
04_check_login.sh Login status verification
05_create_agent.sh Create custom agents
06_run_agents_yaml.sh Run agents from YAML configuration
07_load_markdown.sh Load markdown configurations
08_llm_council.sh LLM Council collaboration
09_heavy_swarm.sh HeavySwarm complex analysis
10_autoswarm.sh Auto swarm builder examples
11_features.sh Feature demonstration
12_help.sh Help and documentation
13_auto_upgrade.sh Automatic upgrade process
14_book_call.sh Book a call functionality
run_all_examples.sh Run all CLI examples

Quick Start

Use Case Example
New to Swarms? Start with single_agent/simple_agent.py for basic concepts
Want to use the CLI? Check out cli/ for all CLI command examples
Want multi-agent workflows? Check out multi_agent/duo_agent.py
Need tool integration? Explore tools/agent_as_tools.py
Interested in AOP? Try aop_examples/client/example_new_agent_tools.py for agent discovery
Want to see social algorithms? Check out multi_agent/social_algorithms_examples/
Looking for guides? Visit guides/ for comprehensive tutorials
Need RAG? Try single_agent/rag/ for RAG examples
Want reasoning agents? Check out reasoning_agents/ for reasoning agent examples
Interested in marketplace prompts? Explore marketplace/ for marketplace prompt integration examples
Want voice/speech capabilities? Check out voice_agents/ for speech-enabled agent examples
Interested in agent skills? Explore single_agent/agent_skill_examples/ for dynamic skills
Want autonomous agents? Check out single_agent/full_autonomy/ for full autonomy examples
Need agent handoffs? See single_agent/handoffs/ for handoff patterns
Looking for latest features? Visit guides/changelog_890/ for January 2026 release examples

Key Examples by Category

Multi-Agent Patterns

Example Description
Duo Agent Two-agent collaboration
Tree Swarm Tree swarm with latest updates
Agent Rearrange Agent rearrangement patterns
Agent Router Agent routing implementations
Agent GRPO Agent GRPO examples for math and physics problems
Auto Swarm Builder Auto Swarm Builder (ASB) examples
Batched Grid Workflow Batched grid workflow patterns
Board of Directors Board of directors pattern
Concurrent Processing Concurrent and parallel execution
Council Council pattern with judge evaluation
Council of Judges Council of judges implementations
Debates Multi-agent debate examples
Election Swarm Election and voting swarms
Forest Swarm Forest and tree-based swarms
Hierarchical Swarm Hierarchical agent structures
Heavy Swarm Heavy swarm for complex tasks
Group Chat Multi-agent conversations and interactive group chat implementations
Graph Workflow Graph-based workflows
LLM Council LLM Council collaboration
Majority Voting Majority voting and consensus
Mixture of Agents Mixture of Agents (MOA) examples
Orchestration Agent orchestration patterns
Sequential Workflow Sequential workflow examples
Simulations Multi-agent simulations
Social Algorithms Various social algorithm patterns
Spreadsheet Examples Spreadsheet-based agents
Swarm Router Swarm routing patterns

Single Agent Examples

Example Description
Simple Agent Basic agent setup
Auto Agent Auto agent implementation
Agent Skills Dynamic skills loader and custom skill examples
Autonomous Agents Full autonomy examples with marketplace integration
Agent Handoffs Agent handoff patterns and examples
Marketplace Integration Marketplace prompt integration examples
Reasoning Agents Advanced reasoning patterns including consistency, GPK, iterative, and reasoning duo
Vision Agents Vision and multimodal capabilities
RAG Agents Retrieval augmented generation
External Agents External agent integrations
Onboarding Agent onboarding examples
Tools Integration Comprehensive tool integration examples
Voice Agents Speech-enabled agent examples

Tool Integrations

Example Description
Agent as Tools Using agents as tools
Browser Automation Browser control
Browser Demo Browser automation demonstration
Claude as Tool Claude model as a tool
Exa Search Search integration
Exa Search Quant Exa search with quantitative analysis
Firecrawl Firecrawl web scraping integration
Stagehand UI automation
Base Tools Base tool implementation examples
Multi-Tool Use Multi-tool usage examples

Model Integration Examples

Example Description
OpenAI OpenAI models
Claude Claude models
DeepSeek DeepSeek models
DeepSeek Groq DeepSeek with Groq integration
Azure Azure OpenAI
Mistral Mistral models
O3 O3 model integration
Qwen Qwen model integration
Ollama Local Ollama models
Cerebras Cerebras model integration
Lumo Lumo model integration
GPT-5 GPT-5 model examples
GPT-OSS GPT-OSS examples
Llama 4 Llama 4 examples
vLLM vLLM integration examples

Marketplace Examples

Example Description
Marketplace Prompt Using marketplace prompts with agents
Quant Trader Agent Quantitative trader agent with marketplace prompts
Zia Agent Zia agent with marketplace prompt integration

CLI Examples

Example Description
Setup Check Verify environment setup
Onboarding User onboarding process
Get API Key API key retrieval
Check Login Login status verification
Create Agent Create custom agents via CLI
Run Agents YAML Run agents from YAML configuration
Load Markdown Load markdown configurations
LLM Council Run LLM Council collaboration
HeavySwarm Run HeavySwarm for complex tasks
AutoSwarm Auto swarm builder examples
Features Feature demonstration
Help Help and documentation
Auto Upgrade Automatic upgrade process
Book Call Book a call functionality
Research Agent Research agent example
Run All Examples Run all CLI examples

Documentation

Each subdirectory contains its own README.md file with detailed descriptions and links to all available examples. Click on any folder above to explore its specific examples and use cases.

Related Resources

Contributing

Found an interesting example or want to add your own? Check out our contributing guidelines and feel free to submit pull requests with new examples or improvements to existing ones.


This examples directory is continuously updated with new patterns, integrations, and use cases. Check back regularly for the latest examples!