OpenSwarm includes a production-ready HTTP API mode powered by Agency Swarm’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/UnkleFunk/HouseMusicSwarm-/llms.txt
Use this file to discover all available pages before exploring further.
run_fastapi integration. Instead of the interactive terminal UI, python server.py starts a FastAPI application that accepts JSON requests, routes them through the multi-agent pipeline, and streams responses back over HTTP. This is the default mode when running in Docker and the right choice for any headless deployment — CI pipelines, hosted servers, or integrations with other services.
Starting the server
localhost:8080 and exposes the OpenAPI documentation at http://localhost:8080/docs. All agency endpoints are mounted under their configured name (e.g., /open-swarm/).
server.py
run_fastapi accepts a dict of agency factories rather than already-instantiated agencies. Each factory is a callable that returns a configured Agency object — this lets the server create a fresh agency instance per request, which keeps thread state isolated. load_dotenv() is called before the import chain so all API keys are in the environment before any agent initializes.
Agency routing
Theagencies dict is a simple name-to-factory map. The key becomes the URL prefix for that agency’s endpoints:
| Key | Factory | Endpoint prefix |
|---|---|---|
"open-swarm" | create_agency | /open-swarm/ |
create_agency factory (defined in swarm.py) instantiates all ten agents, defines SendMessage and Handoff communication flows, loads shared_instructions.md, and returns the configured Agency object.
Configuration
| Parameter | Value | Description |
|---|---|---|
port | 8080 | TCP port the server listens on |
enable_logging | True | Streams agent reasoning steps to stdout at INFO level |
allowed_local_file_dirs | ["./uploads"] | Directories the server may read local files from when processing file-based requests; the uploads/ folder is the designated drop point for attachments |
uploads/ directory is also mapped as a Docker volume (./uploads:/app/uploads) so files written there persist across container restarts and are accessible from the host.
Adding more agencies
To expose a second agency on the same server — for example a stripped-down music-only swarm — add a second factory to theagencies dict:
/music-swarm/ while the original remains at /open-swarm/. Both share the same process and the same .env configuration but maintain completely separate agent threads and state.
Running If you used the onboarding wizard (
python server.py directly requires all Python dependencies to be installed. Install them with:python run.py) or the Docker path, these dependencies are already satisfied. The npm install step applies the patches/ directory via patch-package, which fixes upstream bugs in the Agency Swarm framework — it must run before the server starts.