POST /v1/swarm/completions is the primary endpoint of the Swarms API. One request describes a whole multi-agent system — the roster, the architecture that coordinates it, and the task — and the response returns the swarm’s output along with timing and usage.
This page is the complete field-by-field reference. For a conceptual introduction, start with Multi-Agent Overview; for guidance on picking a topology, see Available Architectures.
Endpoint
Authentication
Every request requires your API key in thex-api-key header. Get one from the API Keys page.
The batch variant,
/v1/swarm/batch/completions, accepts an array of these same SwarmSpec objects (at most 50 per request) and is premium-gated. The single endpoint documented here is not.Request Body: SwarmSpec
Every field is optional at the schema level, but a request with notask (or tasks/messages) and no agents has nothing to run. In practice you always send agents, swarm_type, and a task.
Core Parameters
Architecture-Specific Parameters
These only take effect for their correspondingswarm_type. Sending them with a different architecture is harmless but has no effect.
Swarm Types
swarm_type accepts one of the following 16 values:
BatchedGridWorkflow also has a dedicated premium endpoint, /v1/batched-grid-workflow/completions, and GraphWorkflow is not a swarm_type at all — it has its own endpoint at /v1/graph-workflow/completions.AgentSpec
Each entry inagents is an AgentSpec. Every field is optional.
Identity and Model
Generation Controls
Looping and Tools
selected_tools accepts: create_plan, think, subtask_done, complete_task, respond_to_user, create_file, update_file, read_file, list_directory, delete_file, create_sub_agent, assign_task. run_bash is not permitted.Reasoning
Marketplace Publishing
Set when you want the agent listed on the Swarms Marketplace as a side effect of the run.MCPConnection
Passed asmcp_config on an AgentSpec. Accepts additional properties beyond those listed.
MCP Authentication
stdio Transport
Only used whentransport is "stdio".
MultipleMCPConnections
MCPOAuthConfig
Three flavors are supported: the interactiveauthorization_code browser flow (PKCE and dynamic client registration handled for you, so client_id is optional), the headless client_credentials flow, or supplying a pre-obtained access_token so no flow runs at all.
Response: SwarmCompletion
All nine fields are always present in a successful response.Errors
HTTPValidationError
A422 returns a detail array with one ValidationError per offending field:
max_loops above 50, agents longer than 2000, max_tokens below 1, temperature outside 0–2, a swarm_type outside the enum, or AgentRearrange without rearrange_flow.
Examples
Basic Swarm Completion
- Python
- JavaScript
- Shell (curl)
Architecture-Specific Parameters
HierarchicalSwarm with a tuned director, and AgentRearrange with an explicit flow:
HeavySwarm builds its own agents internally — pass "agents": []. See HeavySwarm.Streaming
Setstream: true to receive output as it is produced rather than waiting for the full run.
Related Resources
Multi-Agent Overview
Conceptual introduction to swarms
Available Architectures
Pick the right topology for your task
Batch Swarm Completions
Run up to 50 swarms in one request
Agent Completions
The single-agent endpoint
Graph Workflow
DAG orchestration on its own endpoint
Pricing
How swarm runs are billed