Explore all available swarm architectures supported by the Swarms API. The /v1/swarms/available
endpoint provides information about different swarm types, their capabilities, and use cases.
Different swarm types are optimized for different workflows - choose the right architecture for your specific needs.
Quick Start
import requests
import json
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://swarms-api-285321057562.us-east1.run.app"
headers = {
"x-api-key": API_KEY,
"Content-Type": "application/json"
}
def get_swarm_types():
"""Get all available swarm types"""
response = requests.get(
f"{BASE_URL}/v1/swarms/available",
headers=headers
)
if response.status_code == 200:
return response.json()
else:
print(f"Error: {response.status_code} - {response.text}")
return None
# Get swarm types
swarm_data = get_swarm_types()
if swarm_data:
print("✅ Swarm types retrieved successfully!")
print(json.dumps(swarm_data, indent=2))
Swarm Type Selection Guide
For Different Use Cases
Complex Problem Solving
Step-by-Step Processes
Parallel Processing
Dynamic Optimization
# Use MixtureOfAgents for diverse expertise
swarm_config = {
"name": "Research Swarm",
"description": "Multi-disciplinary research team",
"agents": [
{
"agent_name": "Data Analyst",
"model_name": "gpt-4o",
"role": "analyst"
},
{
"agent_name": "Domain Expert",
"model_name": "gpt-4o",
"role": "expert"
}
],
"swarm_type": "MixtureOfAgents",
"task": "Analyze market trends and provide strategic recommendations"
}
Swarm Type Comparison
Swarm Type | Best For | Execution | Complexity | Scalability |
---|
MixtureOfAgents | Complex problems, diverse expertise | Parallel | High | High |
SequentialWorkflow | Step-by-step processes, pipelines | Sequential | Medium | Medium |
ConcurrentWorkflow | Independent tasks, batch processing | Parallel | Low | High |
AgentRearrange | Adaptive workflows, optimization | Dynamic | High | Medium |
GroupChat | Collaborative discussions, brainstorming | Interactive | Medium | Low |
HierarchicalSwarm | Structured organizations, management | Hierarchical | High | Medium |
Advanced Swarm Configuration
Hierarchical Swarm
Group Chat Swarm
swarm_config = {
"name": "Corporate Analysis Department",
"description": "Hierarchical corporate structure",
"agents": [
{
"agent_name": "CEO Agent",
"model_name": "gpt-4o",
"role": "executive"
},
{
"agent_name": "Manager Agent",
"model_name": "gpt-4o",
"role": "manager"
},
{
"agent_name": "Analyst Agent 1",
"model_name": "gpt-4o-mini",
"role": "analyst"
},
{
"agent_name": "Analyst Agent 2",
"model_name": "gpt-4o-mini",
"role": "analyst"
}
],
"swarm_type": "HierarchicalSwarm",
"rules": "CEO delegates to managers, managers coordinate analysts",
"task": "Conduct comprehensive market analysis"
}
Load Balancing
Cost Optimization
Quality Optimization
def optimize_swarm_for_load(tasks, available_resources):
"""Optimize swarm configuration based on load"""
task_count = len(tasks)
resource_count = len(available_resources)
if task_count > resource_count * 2:
# High load - use concurrent processing
return {
"swarm_type": "ConcurrentWorkflow",
"max_concurrent": resource_count,
"task_distribution": "round_robin"
}
elif task_count > resource_count:
# Medium load - use mixture of agents
return {
"swarm_type": "MixtureOfAgents",
"load_balancing": True
}
else:
# Low load - use sequential for quality
return {
"swarm_type": "SequentialWorkflow",
"optimize_quality": True
}
Best Practices
Swarm Design
- Match Type to Task: Choose swarm type based on your specific requirements
- Agent Diversity: Use diverse agents with different expertise areas
- Clear Roles: Define clear roles and responsibilities for each agent
- Communication Protocols: Establish clear communication patterns
- Resource Allocation: Allocate resources based on task complexity
- Load Balancing: Distribute work evenly across agents
- Monitoring: Monitor swarm performance and adjust configuration
- Scalability: Design swarms that can scale with increased load
Quality Assurance
- Testing: Test swarm configurations with sample tasks
- Validation: Validate outputs against expected results
- Feedback Loops: Implement feedback mechanisms for improvement
- Version Control: Track swarm configuration versions
Cost Management
- Model Selection: Choose appropriate models based on task requirements
- Resource Limits: Set appropriate limits to control costs
- Usage Monitoring: Monitor resource usage and costs
- Optimization: Continuously optimize for cost efficiency