Swarms CLI Overview
The Swarms CLI is a powerful command-line interface that provides comprehensive tools for creating, managing, and executing AI agents and swarms. It offers an intuitive way to interact with the Swarms framework directly from your terminal.Installation
The Swarms CLI is included with the main Swarms package:Quick Start
Get started with these common commands:Environment Setup
Check your environment configuration:Interactive Chat Agent
Start a chat session with an AI agent:Create a Custom Agent
Create and run a custom agent:--task is omitted, the CLI creates the agent and prints its configuration without running it — it does not drop you into a REPL. Use swarms chat for an interactive session.
Available Commands
The Swarms CLI provides the following command categories:Setup & Configuration
init- Scaffold a new project with .env, workspace directory, and validationonboarding- Run environment setup checksetup-check- Comprehensive environment diagnosticsget-api-key- Open the Swarms API key page in your browsercheck-login- Write a local login marker (no credentials are checked)
Agent Operations
agent- Create and run custom agentschat- Interactive chat agent with optimized defaults (default modelgpt-5.1)run-agents- Execute agents from YAML configurationload-markdown- Load agents from markdown files
Swarm Operations
autoswarm- Generate and execute autonomous swarmsheavy-swarm- Run HeavySwarm for complex task analysis (currently broken in 15.0.3; see heavy-swarm)llm-council- Run LLM Council with collaborative agents
Discovery
models- List, search, and inspect LLM models available via LiteLLMtips- Show rotating tips and tricks for the CLI
Utilities
upgrade- Update Swarms to the latest version
Getting Help
For the full command and flag reference:--help table omits the tips and models commands and shows some stale defaults. The Commands Reference reflects the actual parser.
Environment Variables
The CLI uses several environment variables for configuration:OPENAI_API_KEY- OpenAI API keyANTHROPIC_API_KEY- Anthropic API keyGOOGLE_API_KEY- Google API keyCOHERE_API_KEY- Cohere API keyGROQ_API_KEY- Groq API keyMISTRAL_API_KEY- Mistral API keyTOGETHER_API_KEY- Together AI API keyXAI_API_KEY- xAI / Grok API key (offered byswarms init)OPENROUTER_API_KEY- OpenRouter API key (offered byswarms init)SWARMS_API_KEY- Swarms platform key, required for--marketplace-prompt-idWORKSPACE_DIR- Directory for agent state and logs (default:./agent_workspace)SWARMS_TELEMETRY_ON- Set tofalseto opt out of OpenTelemetry tracing, which is on by default
.env file or export them directly. The CLI loads the nearest .env, searching upward from the current directory, and never overrides a variable you already exported:
./conversations/, agent state and logs go to WORKSPACE_DIR, and ~/.swarms/ only caches MCP OAuth tokens.
Next Steps
Commands Reference
Explore all available CLI commands in detail
Configuration
Learn how to configure agents using YAML and environment variables