Key Features
- Single Agent Operations: Deploy individual AI agents for specific tasks
- Multi-Agent Swarms: Coordinate multiple agents working together
- Sequential Workflows: Agents work in ordered sequence, building on previous outputs
- Concurrent Workflows: Agents work in parallel for faster processing
- Tools Integration: Extend agent capabilities with custom functions
- Multiple Model Support: Choose from OpenAI, Anthropic, and Groq models
Getting Started
Prerequisites
Before you begin, ensure you have:- Python 3.7+ or Node.js for JavaScript/TypeScript
- An API key from Swarms Platform
- Required libraries installed
Installation
Python:Authentication
The API uses API key authentication through thex-api-key
header. Store your API key securely as an environment variable.
Base URLs:
- Production:
https://api.swarms.world
- Alternative:
https://swarms-api-285321057562.us-east1.run.app
Single Agent Usage
Single agents are ideal for focused tasks that donβt require collaboration between multiple AI systems.Basic Health Check
Before making API calls, verify your connection: Python:Creating a Basic Agent
A single agent requires an agent configuration and a task to execute: Python:Agent Configuration Parameters
- agent_name: Descriptive name for your agent
- description: Brief description of the agentβs purpose
- system_prompt: Detailed instructions defining the agentβs role and capabilities
- model_name: AI model to use (see supported models section)
- role: Agent role, typically βworkerβ
- max_loops: Maximum number of processing loops
- max_tokens: Maximum response length
- temperature: Response creativity (0.0 = deterministic, 1.0 = creative)
- auto_generate_prompt: Whether to auto-enhance the system prompt
- tools_list_dictionary: Optional tools for extended functionality
Maintaining Conversation History
For multi-turn conversations, include previous messages in the history parameter: Python:Multi-Agent Swarms
Multi-agent swarms enable complex problem-solving by coordinating multiple AI agents. Swarms support two primary workflow types:Workflow Types
Sequential Workflow: Agents execute in order, with each agent building upon the previous agentβs output. This is ideal for tasks requiring step-by-step processing. Concurrent Workflow: Agents work simultaneously on the same task, providing parallel processing for faster results and diverse perspectives.Sequential Workflow Example
Sequential workflows are perfect for analysis pipelines where each step depends on the previous one: Python:Concurrent Workflow Example
Concurrent workflows are ideal when you need multiple perspectives or parallel processing: Python:Batch Processing
Process multiple swarms in a single request for improved efficiency: Python:Advanced Features
Tools Integration
Enhance agent capabilities by providing specialized tools. Tools are defined using OpenAPI-style function specifications: Python:Tool Definition Guidelines
When creating tools for your agents:- Clear Names: Use descriptive function names that clearly indicate the toolβs purpose
- Detailed Descriptions: Provide comprehensive descriptions of what the tool does
- Parameter Specifications: Define all parameters with appropriate types and descriptions
- Required Fields: Specify which parameters are mandatory
- Usage Context: Include guidance in the system prompt about when to use specific tools
Supported Models
Choose the appropriate model based on your use case requirements:OpenAI Models
- gpt-4: High-quality reasoning and complex task handling
- gpt-4o: Optimized version with improved performance
- gpt-4o-mini: Lightweight version for faster responses
Anthropic Models
- claude-sonnet-4-20250514-20240620: Balanced performance and reasoning
- claude-3-7-sonnet-latest: Latest Claude model with enhanced capabilities
Groq Models
- groq/llama3-70b-8192: High-performance open-source model
- groq/deepseek-r1-distill-llama-70b: Specialized reasoning model
Model Selection Guidelines
- Complex Analysis: Use GPT-4 or Claude-3.5-Sonnet for tasks requiring deep reasoning
- Fast Responses: Choose GPT-4o-mini for quick, straightforward tasks
- Creative Tasks: Higher temperature settings work better with creative models
- Factual Tasks: Lower temperature settings provide more consistent, factual responses
API Reference
Endpoints
Single Agent Completions:POST /v1/agent/completions
POST /v1/swarm/completions
POST /v1/swarm/batch/completions
GET /health
Best Practices
Security
- Never commit API keys to version control
- Use environment variables for all sensitive configuration
- Implement proper access controls in production environments
- Regularly rotate API keys
Error Handling
Implement robust error handling for production applications: Python:Rate Limiting
- Implement exponential backoff for failed requests
- Monitor your API usage to stay within limits
- Use batch processing when possible to reduce individual request volume
Performance Optimization
- Cache responses when appropriate
- Use concurrent workflows for independent tasks
- Choose the right model for your specific use case
- Optimize token usage by being specific in your prompts
Testing Strategy
- Start with simple, single-agent tasks
- Test with different models to find the best fit
- Gradually increase complexity as you understand the system
- Implement comprehensive logging for debugging
Troubleshooting
Common Issues
Authentication Errors:- Verify your API key is correct and active
- Check that the
x-api-key
header is properly set - Ensure your API key has the necessary permissions
- Increase request timeout values
- Consider breaking complex tasks into smaller chunks
- Use batch processing for multiple operations
- Check if your requested model is currently available
- Have fallback models configured
- Monitor model status through the health endpoint
- Ensure all required fields are present
- Validate data types match the expected format
- Check that tool definitions follow the correct schema
Getting Help
Community Resources
- Documentation: docs.swarms.world
- Discord Community: Join Discord
- Technical Blog: Medium
Professional Support
- Onboarding Sessions: Book with Kye Gomez
- Enterprise Support: Contact through the platform
Stay Updated
- Twitter: @kyegomez
- LinkedIn: The Swarm Corporation
- YouTube: Swarms Channel
- Community Events: Sign up here