Use this file to discover all available pages before exploring further.
Agents are the fundamental building blocks of the Swarms framework. An agent is an autonomous entity powered by an LLM with tools, memory, and the ability to execute complex tasks.
The simplest way to create an agent is to instantiate the Agent class with minimal configuration:
from swarms import Agent# Create a basic agentagent = Agent( agent_name="my-agent", model_name="gpt-5.4", max_loops=1,)# Run the agentresponse = agent.run("What are the key benefits of using a multi-agent system?")print(response)
agent = Agent( agent_name="Assistant", model_name="gpt-5.4", max_loops=5, interactive=True, # Enable interactive mode user_name="User", custom_exit_command="exit",)# Agent will prompt for user input in a loopagent.run("Hello! How can I help you today?")
import os# Set your Swarms API keyos.environ["SWARMS_API_KEY"] = "your-api-key"agent = Agent( model_name="claude-sonnet-4-6", marketplace_prompt_id="550e8400-e29b-41d4-a716-446655440000", # UUID from marketplace max_loops=1,)# System prompt is automatically loaded from the marketplaceresponse = agent.run("Execute the marketplace prompt task")
# Good - Specific and detailedsystem_prompt = """You are a healthcare data analyst specializing in:1. Patient data analysis2. Medical coding (ICD-10, CPT)3. HIPAA compliance4. Clinical research metricsAlways maintain patient privacy and follow HIPAA guidelines."""# Avoid - Too vaguesystem_prompt = "You are a helpful assistant."
code_agent = Agent( agent_name="Code-Generator", system_prompt="You are an expert software engineer. Write clean, documented code.", model_name="claude-sonnet-4-6", max_loops=2, temperature=0.3, # Lower temperature for more deterministic output)