Swarms AI — Multi-Agent Orchestration
Build production-grade multi-agent systems using the Swarms API platform. Supports single agents, reasoning agents, and swarms of 3–10,000+ agents with 20+ architecture patterns.
Quick Reference
Architecture Tiers
| Tier | Name | Agents | Endpoint |
|---|
| 1 | Individual Agent | 1 | INLINECODE4 |
| 2 |
Reasoning Agent | 1-2 internal |
/v1/reasoning-agent/completions |
| 3 | Multi-Agent Swarm | 3–10,000+ |
/v1/swarm/completions |
Workflow
1. Single Agent
CODEBLOCK0
2. Multi-Agent Swarm
CODEBLOCK1
3. Token Launch (Solana)
CODEBLOCK2
Available Swarm Architectures
Use the swarm_type parameter:
| Type | Description | Best For |
|---|
| INLINECODE8 | Linear pipeline, each agent builds on previous | Step-by-step processing |
| INLINECODE9 |
Parallel execution | Independent tasks, speed |
|
AgentRearrange | Dynamic agent reordering | Adaptive workflows |
|
MixtureOfAgents | Specialist agent selection | Multi-domain tasks |
|
MultiAgentRouter | Intelligent task routing | Large-scale distribution |
|
HierarchicalSwarm | Nested hierarchies with delegation | Complex org structures |
|
MajorityVoting | Consensus across agents | Decision making |
|
BatchedGridWorkflow | Grid pattern execution | Multi-task × multi-agent |
|
GraphWorkflow | Directed graph of agent nodes | Complex dependencies |
|
GroupChat | Agent discussion | Collaborative brainstorming |
|
InteractiveGroupChat | Real-time agent interaction | Dynamic collaboration |
|
AutoSwarmBuilder | Auto-generate optimal swarm | When unsure of architecture |
|
HeavySwarm | High-capacity processing | Large workloads |
|
DebateWithJudge | Structured debate | Adversarial evaluation |
|
RoundRobin | Round-robin distribution | Even load distribution |
|
MALT | Multi-agent learning | Training systems |
|
CouncilAsAJudge | Expert panel evaluation | Quality assessment |
|
LLMCouncil | LM council for decisions | Group decision making |
|
AdvancedResearch | Research workflows | Deep research |
|
auto | Auto-select best type | Default/unknown |
Agent Config Parameters
| Param | Type | Default | Description |
|---|
| INLINECODE28 | string | — | Unique agent identifier |
| INLINECODE29 |
string | — | Agent purpose |
|
system_prompt | string | — | Behavior instructions |
|
model_name | string |
gpt-4.1 | AI model (gpt-4o, claude-sonnet-4-20250514, etc.) |
|
role | string |
worker | Agent role in swarm |
|
max_loops | int/string |
1 | Iterations (
"auto" for autonomous) |
|
max_tokens | int |
8192 | Max response length |
|
temperature | float |
0.5 | Creativity (0.0–2.0) |
|
auto_generate_prompt | bool |
false | Auto-enhance system prompt |
|
tools_list_dictionary | list | — | OpenAPI-style tool definitions |
|
streaming_on | bool |
false | Enable SSE streaming |
|
mcp_url | string | — | MCP server URL |
|
selected_tools | list | all safe | Restrict available tools |
Rules
- - Always use environment variables for API keys — never hardcode.
- Set appropriate
max_loops — use "auto" only when sub-agent delegation is needed. - Match
swarm_type to use case (see architecture table). - For streaming, set
streaming_on: true and parse SSE events (metadata → chunks → usage → done). - Token launches cost ~0.04 SOL from the provided wallet.
- Batch endpoint (
/v1/swarm/batch/completions) requires Pro/Ultra/Premium tier. - Reasoning agents (
/v1/reasoning-agent/completions) require Pro+ tier.
Resource Map
| Topic | Reference |
|---|
| Full API architecture & tiers | INLINECODE55 |
| Sub-agent delegation patterns |
references/sub-agents.md |
| ATP payment protocol (Solana) |
references/atp-protocol.md |
| Marketplace publishing |
references/marketplace.md |
| Streaming implementation |
references/streaming.md |
| Tools integration |
references/tools.md |
| All docs pages | https://docs.swarms.ai/llms.txt |
Read references only when the task requires that specific depth.
Swarms AI — 多智能体编排
使用 Swarms API 平台构建生产级多智能体系统。支持单智能体、推理智能体以及3至10,000+智能体的群体,提供20多种架构模式。
快速参考
架构层级
| 层级 | 名称 | 智能体数量 | 端点 |
|---|
| 1 | 单智能体 | 1 | /v1/agent/completions |
| 2 |
推理智能体 | 1-2(内部) | /v1/reasoning-agent/completions |
| 3 | 多智能体群体 | 3–10,000+ | /v1/swarm/completions |
工作流程
1. 单智能体
python
import requests
payload = {
agent_config: {
agent_name: MyAgent,
description: 智能体的用途,
system_prompt: 你是...,
model_name: gpt-4o, # 或 claude-sonnet-4-20250514 等
role: worker,
max_loops: 1,
max_tokens: 8192,
temperature: 0.5,
autogenerateprompt: False,
toolslistdictionary: None
},
task: 你的任务在此
}
response = requests.post(
https://api.swarms.world/v1/agent/completions,
headers={x-api-key: API_KEY, Content-Type: application/json},
json=payload
)
2. 多智能体群体
python
payload = {
name: 我的群体,
description: 该群体的功能,
agents: [
{
agent_name: Agent1,
description: 角色1,
system_prompt: 你是...,
model_name: gpt-4o,
role: worker,
max_loops: 1,
max_tokens: 8192,
temperature: 0.5
},
{
agent_name: Agent2,
description: 角色2,
system_prompt: 你是...,
model_name: claude-sonnet-4-20250514,
role: worker,
max_loops: 1,
max_tokens: 8192,
temperature: 0.5
}
],
max_loops: 1,
swarm_type: SequentialWorkflow, # 参见架构表
task: 你的任务在此
}
response = requests.post(
https://api.swarms.world/v1/swarm/completions,
headers={x-api-key: API_KEY, Content-Type: application/json},
json=payload
)
3. 代币发布(Solana)
python
payload = {
name: 我的智能体代币,
description: 智能体描述,
ticker: MAG,
private_key: [1,2,3,...] # Solana钱包私钥
}
response = requests.post(
https://swarms.world/api/token/launch,
headers={Authorization: Bearer API_KEY, Content-Type: application/json},
json=payload
)
返回: tokenaddress, pooladdress, listing_url
成本: ~0.04 SOL
可用的群体架构
使用 swarm_type 参数:
| 类型 | 描述 | 最佳用途 |
|---|
| SequentialWorkflow | 线性管道,每个智能体基于前一个构建 | 逐步处理 |
| ConcurrentWorkflow |
并行执行 | 独立任务,追求速度 |
| AgentRearrange | 动态智能体重排 | 自适应工作流 |
| MixtureOfAgents | 专家智能体选择 | 多领域任务 |
| MultiAgentRouter | 智能任务路由 | 大规模分发 |
| HierarchicalSwarm | 带委托的嵌套层级 | 复杂组织结构 |
| MajorityVoting | 跨智能体共识 | 决策制定 |
| BatchedGridWorkflow | 网格模式执行 | 多任务×多智能体 |
| GraphWorkflow | 智能体节点的有向图 | 复杂依赖关系 |
| GroupChat | 智能体讨论 | 协作头脑风暴 |
| InteractiveGroupChat | 实时智能体交互 | 动态协作 |
| AutoSwarmBuilder | 自动生成最优群体 | 不确定架构时 |
| HeavySwarm | 高容量处理 | 大型工作负载 |
| DebateWithJudge | 结构化辩论 | 对抗性评估 |
| RoundRobin | 轮询分发 | 均匀负载分配 |
| MALT | 多智能体学习 | 训练系统 |
| CouncilAsAJudge | 专家小组评估 | 质量评估 |
| LLMCouncil | 语言模型委员会决策 | 群体决策 |
| AdvancedResearch | 研究工作流 | 深度研究 |
| auto | 自动选择最佳类型 | 默认/未知情况 |
智能体配置参数
| 参数 | 类型 | 默认值 | 描述 |
|---|
| agent_name | 字符串 | — | 唯一智能体标识符 |
| description |
字符串 | — | 智能体用途 |
| system_prompt | 字符串 | — | 行为指令 |
| model_name | 字符串 | gpt-4.1 | AI模型(gpt-4o、claude-sonnet-4-20250514等) |
| role | 字符串 | worker | 智能体在群体中的角色 |
| max_loops | 整数/字符串 | 1 | 迭代次数(auto表示自主) |
| max_tokens | 整数 | 8192 | 最大响应长度 |
| temperature | 浮点数 | 0.5 | 创造力(0.0–2.0) |
| auto
generateprompt | 布尔值 | false | 自动增强系统提示 |
| tools
listdictionary | 列表 | — | OpenAPI风格工具定义 |
| streaming_on | 布尔值 | false | 启用SSE流式传输 |
| mcp_url | 字符串 | — | MCP服务器URL |
| selected_tools | 列表 | 全部安全 | 限制可用工具 |
规则
- - 始终使用环境变量存储API密钥——切勿硬编码。
- 设置适当的 maxloops——仅在需要子智能体委托时使用 auto。
- 根据用例匹配 swarmtype(参见架构表)。
- 如需流式传输,设置 streaming_on: true 并解析SSE事件(元数据→数据块→使用情况→完成)。
- 代币发布从提供的钱包中消耗约0.04 SOL。
- 批量端点(/v1/swarm/batch/completions)需要Pro/Ultra/Premium层级。
- 推理智能体(/v1/reasoning-agent/completions)需要Pro+层级。
资源映射
| 主题 | 参考 |
|---|
| 完整API架构与层级 | references/architecture.md |
| 子智能体委托模式 |
references/sub-agents.md |
| ATP支付协议(Solana) | references/atp-protocol.md |
| 市场发布 | references/marketplace.md |
| 流式传输实现 | references/streaming.md |
| 工具集成 | references/tools.md |
| 所有文档页面 | https://docs.swarms.ai/llms.txt |
仅在任务需要特定深度时阅读参考文档。