Skip to main content
This page covers advanced multi-agent architectures and workflows using raw HTTP requests (no client SDK). All examples use the base URL:
https://api.swarms.world
Many of these endpoints are premium‑only and require Pro, Ultra, or Premium plans. See Premium Endpoints.

Advanced Research

The Advanced Research API provides a sophisticated multi-agent research system that combines director and worker agents to conduct comprehensive research tasks. The system leverages external search capabilities and supports both single and batch processing modes.
Premium: These endpoints are available only on Pro and Ultra plans: POST /v1/advanced-research/completions and POST /v1/advanced-research/batch/completions. See Pricing.
The Advanced Research system uses a director-worker architecture for coordinated, comprehensive research with external search integration.

Quick Start

import requests
import os

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json"
}

payload = {
    "config": {
        "name": "AI Ethics Research",
        "description": "Research on AI ethics and responsible AI development",
        "worker_model_name": "gpt-4.1",
        "director_model_name": "gpt-4.1",
        "max_loops": 1,
        "exa_search_num_results": 3
    },
    "task": "What are the key ethical considerations in developing AI systems?"
}

response = requests.post(
    f"{BASE_URL}/v1/advanced-research/completions",
    headers=headers,
    json=payload
)

response.raise_for_status()
result = response.json()
print(result["outputs"])

Key Features

Multi-Agent Architecture

  • Director Agent: Orchestrates the research process and synthesizes results
  • Worker Agents: Execute specific research tasks and gather information
  • External Search: Integrates with Exa search for web research capabilities

Configurable Models

  • Support for multiple LLM providers (OpenAI, Anthropic, etc.)
  • Separate models for director and worker agents
  • Customizable token limits and loops

Cost Tracking

  • Transparent token usage reporting
  • Real-time cost calculation
  • Credit system integration

Use Cases

  • Academic Research: Comprehensive literature reviews and analysis
  • Market Research: Competitive analysis and trend identification
  • Technical Documentation: In-depth analysis of technical topics
  • Policy Research: Analysis of regulations and their implications
  • Innovation Research: Exploring emerging technologies and their applications

Batch Processing

Process multiple research tasks in parallel:
import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json"
}

def run_batch_research():
    batch_payload = {
        "input_schemas": [
            {
                "config": {
                    "name": "Healthcare AI",
                    "description": "AI in healthcare research",
                    "worker_model_name": "gpt-4.1",
                    "director_model_name": "gpt-4.1"
                },
                "task": "How is AI transforming healthcare?"
            },
            {
                "config": {
                    "name": "Sustainable Energy",
                    "description": "Renewable energy research",
                    "worker_model_name": "gpt-4.1",
                    "director_model_name": "gpt-4.1"
                },
                "task": "What are the latest breakthroughs in sustainable energy?"
            }
        ]
    }

    response = requests.post(
        f"{BASE_URL}/v1/advanced-research/batch/completions",
        headers=headers,
        json=batch_payload,
        timeout=600.0
    )

    response.raise_for_status()
    return response.json()

if __name__ == "__main__":
    results = run_batch_research()
    print("✅ Batch research completed")
    print(json.dumps(results, indent=2))

Configuration Options

ParameterTypeDefaultDescription
worker_model_namestring”gpt-4.1”Model for worker agents
director_model_namestring”gpt-4.1”Model for director agent
max_loopsinteger1Number of research iterations
director_max_tokensinteger8000Token limit for director
exa_search_num_resultsinteger2Number of search results
exa_search_max_charactersinteger100Characters per search result

Best Practices

  1. Task Specificity: Provide clear, specific research questions
  2. Model Selection: Use more capable models for complex research tasks
  3. Loop Configuration: Increase loops for deeper analysis (2-3 loops recommended)
  4. Search Parameters: Adjust search results based on research scope
  5. Cost Monitoring: Monitor token usage for budget management

Graph Workflow – Multi-Agent DAG

Execute a directed graph of agents with parallel branches using /v1/graph-workflow/completions.
import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json",
}

payload = {
    "name": "Product Launch Graph",
    "description": "Graph workflow for product launch analysis",
    "agents": [
        {
            "agent_name": "Market-Research",
            "description": "Researches the target market.",
            "system_prompt": "You are a market research analyst.",
            "model_name": "gpt-4.1",
        },
        {
            "agent_name": "Tech-Feasibility",
            "description": "Evaluates technical feasibility.",
            "system_prompt": "You are a senior software architect.",
            "model_name": "gpt-4.1",
        },
        {
            "agent_name": "Exec-Summary",
            "description": "Summarizes findings for executives.",
            "system_prompt": "You are a VP of Product summarizing key decisions.",
            "model_name": "gpt-4.1",
        },
    ],
    "edges": [
        {"source": "Market-Research", "target": "Exec-Summary"},
        {"source": "Tech-Feasibility", "target": "Exec-Summary"},
    ],
    "entry_points": ["Market-Research", "Tech-Feasibility"],
    "end_points": ["Exec-Summary"],
    "max_loops": 1,
    "task": "Evaluate launching a new AI assistant for enterprise documentation.",
    "auto_compile": True,
    "verbose": False,
}


def run_graph_workflow():
    resp = requests.post(
        f"{BASE_URL}/v1/graph-workflow/completions",
        headers=headers,
        json=payload,
        timeout=600,
    )
    resp.raise_for_status()
    return resp.json()


if __name__ == "__main__":
    result = run_graph_workflow()
    print(json.dumps(result, indent=2))

Batched Grid Workflow – Tasks × Agents Matrix

Use /v1/batched-grid-workflow/completions to run a grid of agents over a list of tasks.
import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json",
}

payload = {
    "name": "Content Review Grid",
    "description": "Run multiple reviewers across multiple drafts",
    "agent_completions": [
        {
            "agent_name": "Style-Reviewer",
            "description": "Reviews writing style and tone.",
            "system_prompt": "You are an editor focusing on style, tone, and clarity.",
            "model_name": "gpt-4.1",
        },
        {
            "agent_name": "Fact-Checker",
            "description": "Checks factual accuracy.",
            "system_prompt": "You are a fact-checking assistant.",
            "model_name": "gpt-4.1",
        },
    ],
    "tasks": [
        "Review this blog post draft about Swarms API for clarity and style.",
        "Review this changelog entry for accuracy and completeness.",
    ],
    "max_loops": 1,
}


def run_batched_grid_workflow():
    resp = requests.post(
        f"{BASE_URL}/v1/batched-grid-workflow/completions",
        headers=headers,
        json=payload,
        timeout=600,
    )
    resp.raise_for_status()
    return resp.json()


if __name__ == "__main__":
    result = run_batched_grid_workflow()
    print(json.dumps(result, indent=2))

Auto Swarm Builder – Generate Swarms from a Task

The Auto Swarm Builder can design swarms for you based on a textual description.
import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json",
}

payload = {
    "name": "Customer Feedback Analysis Swarm",
    "description": "Automatically design a swarm to cluster and summarize customer feedback.",
    "model_name": "gpt-4.1",
    "max_loops": 1,
    "execution_type": "return-agents",
    "task": "Design a swarm that ingests customer feedback CSVs and produces prioritized issue summaries.",
    "max_tokens": 2000,
}


def run_auto_swarm_builder():
    resp = requests.post(
        f"{BASE_URL}/v1/auto-swarm-builder/completions",
        headers=headers,
        json=payload,
        timeout=600,
    )
    resp.raise_for_status()
    return resp.json()


if __name__ == "__main__":
    result = run_auto_swarm_builder()
    print(json.dumps(result, indent=2))

Execution Types

The Auto Swarm Builder supports multiple execution types that determine the format of the returned output. You can discover available execution types using the /v1/auto-swarm-builder/execution-types endpoint.

Available Execution Types

Execution TypeDescriptionUse Case
return-agentsReturns generated agent configurations as a list of agent objects (default)Most common use case - when you want to use generated agents directly
return-swarm-router-configReturns a swarm router configuration for MultiAgentRouterWhen you want to create an intelligent routing system
return-agents-objectsReturns agent configurations with extended metadata and configuration optionsWhen you need comprehensive agent information

Example: Using Different Execution Types

payload = {
    "name": "Research Swarm",
    "task": "Create a research team for market analysis",
    "execution_type": "return-agents",  # Default
    "model_name": "gpt-4.1"
}
# Returns: {"success": true, "outputs": {"agents": [...]}}
To discover all available execution types dynamically, use the /v1/auto-swarm-builder/execution-types endpoint. This ensures your code works even if new execution types are added in the future.

Reasoning Agent Completions

Run an advanced reasoning agent using /v1/reasoning-agent/completions.
Reasoning agents are premium‑only. Free tier keys will receive 403 responses.
import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")
BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json",
}

payload = {
    "agent_name": "Investment-Reasoner",
    "description": "Multi-step financial reasoning agent.",
    "model_name": "claude-sonnet-4-20250514",
    "swarm_type": "self-consistency",
    "num_samples": 3,
    "output_type": "dict-final",
    "max_loops": 1,
    "task": "Given recent macroeconomic trends, reason about risks and opportunities for a diversified tech portfolio.",
}


def run_reasoning_agent():
    resp = requests.post(
        f"{BASE_URL}/v1/reasoning-agent/completions",
        headers=headers,
        json=payload,
        timeout=600,
    )
    resp.raise_for_status()
    return resp.json()


if __name__ == "__main__":
    result = run_reasoning_agent()
    print(json.dumps(result, indent=2))