Skip to main content
The List Agents endpoint (/v1/agents/list) allows you to retrieve all agent configurations you have previously created through the Swarms API. This endpoint provides a comprehensive view of your agent inventory, including their names, descriptions, system prompts, model configurations, and other settings. When you create agents using the Swarms API (via the /v1/agent/completions endpoint or other agent creation methods), each agent configuration is stored in your account. The List Agents endpoint enables you to:
  • View all your agents: Retrieve a complete list of all agent configurations associated with your API key
  • Manage your agent library: Keep track of different agent configurations you’ve created for various use cases
  • Reuse agent configurations: Access previously created agent settings to reuse them in new tasks or workflows
  • Audit and organize: Review your agent inventory to understand what agents you have available and their configurations

Endpoint Information

  • URL: /v1/agents/list
  • Method: GET
  • Authentication: Required (x-api-key header)
  • Rate Limiting: Subject to tier-based rate limits

Response Format

The endpoint returns a JSON object containing:
  • count: An integer representing the total number of unique agent configurations in your account
  • agents: An array of agent definition objects, each containing the complete configuration details of agents you’ve previously created, including:
    • Agent name and description
    • System prompts
    • Model configurations (model name, temperature, max_tokens, etc.)
    • Tool configurations
    • MCP integrations
    • Other agent-specific settings

Use Cases

  • Agent Discovery: Quickly see what agents you have available without needing to remember specific configuration details
  • Configuration Reuse: Retrieve agent configurations to reuse in new API calls or workflows
  • Inventory Management: Keep track of your agent library and identify agents that may need updates or cleanup
  • Multi-Agent Workflows: List available agents to select and combine them in complex multi-agent architectures
  • Development and Testing: Review agent configurations during development to ensure consistency across different environments
import json
import os
from typing import Any, Dict

import requests
from dotenv import load_dotenv

load_dotenv()

BASE_URL = "https://api.swarms.world"

HEADERS = {
    "x-api-key": os.getenv("SWARMS_API_KEY"),
    "Content-Type": "application/json",
}

def list_agents() -> Dict[str, Any]:
    """Retrieve all unique agent configurations"""
    try:
        response = requests.get(f"{BASE_URL}/v1/agents/list", headers=HEADERS)
        assert response.status_code == 200, f"Expected 200, got {response.status_code}: {response.text}"
        response_data = response.json()

        print(json.dumps(response_data, indent=4))
        count = response_data["count"]
        print(f"Number of agents: {count}")
        return response_data
    except Exception as e:
        print(str(e))
        return {}

if __name__ == "__main__":
    list_agents()
Responses include a count of agents and an array of agent definitions you previously created.