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-5.4, o3
  • Anthropic - Claude 4.x Opus, Sonnet, Haiku
  • Groq - Ultra-fast inference with Llama
  • 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-5.4", "claude-sonnet-4-6"
  • Provider prefix: "groq/llama-3.3-70b-versatile", "ollama/llama3.2"
  • OpenRouter: "openrouter/provider/model-name"
Model names are passed straight to LiteLLM, so any name LiteLLM can route works. To check a name before you build an agent, use is_model_available:
See check_models for the full API.

Advanced Configuration

Custom Model Parameters

Configure model-specific parameters:
temperature defaults to None, which leaves it out of the request so the provider’s own default applies. max_tokens defaults to the model’s own output limit.

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 token usage per agent with agent.usage

Test Thoroughly

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

Fallback Strategy

Set fallback_models so an agent moves to another provider when one fails

Next Steps

MCP Integration

Connect to MCP servers for extended capabilities

Tools

Add custom tools to your agents