Multi-Provider Agents
PraisonAI agents can seamlessly switch between LLM providers like OpenAI, Anthropic, Google, and more. Under the hood, agents are powered by the AI SDK for multi-provider support, but you interact with the simpleAgent abstraction.
Why Multi-Provider?
- Flexibility: Switch providers without changing your agent code
- Cost optimization: Use different models for different tasks
- Redundancy: Fall back to alternative providers if one is unavailable
- Best-of-breed: Use the best model for each use case
Installation
Quick Start
Supported Providers
| Provider | Model String | Examples |
|---|---|---|
| OpenAI | openai/model | openai/gpt-4o, openai/gpt-4o-mini |
| Anthropic | anthropic/model | anthropic/claude-3-5-sonnet-latest |
google/model | google/gemini-2.0-flash | |
| Groq | groq/model | groq/llama-3.3-70b-versatile |
| Mistral | mistral/model | mistral/mistral-large-latest |
| Cohere | cohere/model | cohere/command-r-plus |
| DeepSeek | deepseek/model | deepseek/deepseek-chat |
| xAI | xai/model | xai/grok-2 |
Agent with Different Providers
Agent with Streaming
Agent with Tools
Agent with Structured Output
Multi-Agent Workflows
Backend Selection
Agents automatically select the best backend:| Provider | Backend Used |
|---|---|
| OpenAI | Native OpenAI SDK (fastest) |
| Anthropic | AI SDK |
| AI SDK | |
| Other providers | AI SDK |
Environment Variables
Set API keys for your providers:CLI Usage
Run agents from the command line:Troubleshooting
Provider not found
Ensure you have the provider package installed:API key errors
Check your environment variables are set correctly:Model not available
Verify the model name matches the provider’s naming convention.Advanced: Backend Internals
Advanced: Backend Internals
The AI SDK backend is used internally to provide multi-provider support. You typically don’t need to interact with it directly.The backend resolver automatically:
- Detects installed AI SDK provider packages
- Falls back to native providers when AI SDK is unavailable
- Injects attribution headers for multi-agent tracing
Next Steps
- Agent CLI Commands - Full CLI reference
- Agent Tools - Adding tools to agents
- Structured Output - Type-safe JSON output
- Attribution & Tracing - Multi-agent tracking

