Skip to main content
Swarms supports a wide range of LLM providers, giving you the flexibility to choose the best model for your use case. The framework provides a unified interface that works seamlessly across all supported providers.

Supported Providers

Swarms integrates with all major LLM providers through a consistent API:
  • OpenAI - GPT-4, GPT-4 Turbo, GPT-3.5
  • Anthropic - Claude 3 Opus, Sonnet, Haiku
  • Groq - Ultra-fast inference with Llama, Mixtral
  • DeepSeek - DeepSeek models
  • Cohere - Command models
  • Ollama - Local model deployment
  • OpenRouter - Access to multiple providers
  • XAI - Grok models
  • Azure OpenAI - Enterprise OpenAI deployment

Configuration

Environment Setup

Configure your API keys in environment variables:
Store your API keys in a .env file and use python-dotenv to load them. Never commit API keys to version control.

Usage Examples

OpenAI Models

Use OpenAI’s GPT models by specifying the model name:

Anthropic Claude

Claude models excel at long-form content and analysis:

Groq (Ultra-Fast Inference)

Groq provides extremely fast inference speeds:

DeepSeek

DeepSeek models for coding and reasoning:

Ollama (Local Models)

Run models locally with Ollama:

OpenRouter (Multi-Provider Access)

Access multiple providers through OpenRouter:

Cohere

Cohere Command models:

Model Naming Convention

Swarms uses the following naming pattern for models:
  • Direct provider models: "gpt-4", "claude-3-opus-20240229"
  • Provider prefix: "groq/llama-3.1-70b-versatile", "ollama/llama2"
  • OpenRouter: "openrouter/provider/model-name"

Advanced Configuration

Custom Model Parameters

Configure model-specific parameters:

Dynamic Model Selection

Switch models dynamically based on task requirements:

Multi-Provider Workflows

Combine different providers in a single workflow:

Cost Optimization

Optimize costs by using the right model for each task:

Best Practices

Choose the Right Model

Select models based on your specific use case - speed, cost, or capability

Monitor Usage

Track API usage and costs across different providers

Test Thoroughly

Test with multiple providers to find the best fit for your application

Fallback Strategy

Implement fallback to alternative providers for reliability

Next Steps

MCP Integration

Connect to MCP servers for extended capabilities

Tools

Add custom tools to your agents