Skip to main content

Features

  • Type Safety: Full type definitions for all request params and response fields
  • Dual Clients: Both synchronous and asynchronous clients powered by httpx
  • Comprehensive Coverage: Access to all Swarms API endpoints
  • Modern Python: Built for Python 3.8+ with async/await support
  • Environment Integration: Seamless .env file support for API keys

Installation

Environment Setup

Create a .env file in your project root:

Quick Start

Your First Swarm

Client Configuration

Environment Variable

Set SWARMS_API_KEY in your environment (or a .env file), then load it in your code:

Direct API Key

Custom Configuration

Core Operations

Swarm Management

Model Information

Health and Status

Advanced Usage

Asynchronous Operations

Batch Operations

Helper Methods

The client provides convenient helper methods for common operations:

Examples

Content Generation Swarm

Data Analysis Pipeline

Troubleshooting

Common Issues

  1. API Key Errors: Ensure your API key is valid and properly set in environment variables
  2. Rate Limiting: Check rate limits with client.client.rate.get_limits()
  3. Network Issues: Verify your internet connection and firewall settings
  4. Model Availability: Use client.models.list_available() to check available models

Getting Help