Get Started in Minutes
This guide will walk you through creating your first autonomous agent and multi-agent swarm using Swarms. By the end of this tutorial, you’ll have a working agent and understand how to orchestrate multiple agents to work together.Before you begin, make sure you’ve installed Swarms and configured your environment.
Your First Agent
An Agent is the fundamental building block of a swarm—an autonomous entity powered by an LLM + Tools + Memory.1
Import the Agent class
Start by importing the
Agent class from the swarms package:2
Initialize your agent
Create a new agent with basic configuration:Key Parameters:
model_name: The language model to use (e.g., “gpt-5.4”, “claude-sonnet-4-6”)max_loops: Number of reasoning iterations, or"auto"to let the agent plan, act, and decide when it is done (see Autonomous mode)interactive: Prompt you for follow-up input after each response
3
Run your agent
Execute a task with your agent:
Complete code example
Complete code example
Your First Swarm: Multi-Agent Collaboration
A Swarm consists of multiple agents working together. Let’s create a two-agent workflow for researching and writing a blog post.1
Import required classes
Import both
Agent and SequentialWorkflow:2
Create specialized agents
Define two agents with specific roles:
The
system_prompt defines each agent’s role and responsibilities. Be specific about what you want each agent to do.3
Create a sequential workflow
Connect the agents in a pipeline where the researcher’s output feeds into the writer’s input:
4
Run the workflow
Execute the workflow with a task:The workflow will:
- Send the task to the Researcher agent
- The Researcher analyzes the topic and provides a summary
- The Writer receives the research and creates a blog post
- The final blog post is returned
Complete swarm example
Complete swarm example
Understanding the Workflow
TheSequentialWorkflow executes agents in order, creating a pipeline where each agent builds upon the work of the previous one. This is ideal for:
- Research → Analysis → Writing workflows
- Data Collection → Processing → Reporting pipelines
- Planning → Execution → Review processes
- Any task with clear sequential dependencies
Want to run agents in parallel instead? Check out ConcurrentWorkflow for simultaneous execution.
What You Can Do Next
Add Tools to Your Agent
Extend your agent’s capabilities with external tools and APIs
Explore Multi-Agent Architectures
Learn about HierarchicalSwarm, ConcurrentWorkflow, MixtureOfAgents, and more
Use Different Model Providers
Connect to OpenAI, Anthropic, Groq, Cohere, and other LLM providers
Build Production Applications
Handle errors, control costs, and scale agents in production
Common Use Cases
Single Agent Examples
Multi-Agent Examples
Troubleshooting
Agent not responding
Agent not responding
Make sure your API keys are properly configured in your
.env file. Check the environment setup guide for details.Model not found error
Model not found error
Verify that you’re using a valid model name. See the Model Providers documentation for supported models.
Rate limit errors
Rate limit errors
Use
max_loops=1 to reduce API calls. Each agent already retries a failed LLM call retry_attempts times (default 3); after that, run() tries any fallback_models you configured and then raises AgentLLMError. Catch it to add your own backoff.Next Steps
Now that you’ve created your first agent and swarm, you’re ready to:- Customize your agents with specific system prompts and configurations
- Add tools to extend agent capabilities
- Explore different workflows like HierarchicalSwarm and MixtureOfAgents
- Build production applications with advanced features
Join our Discord community to get help, share your projects, and connect with other Swarms developers!