llm parameter — PraisonAI routes to OpenAI, Anthropic, Gemini, Groq, Cohere, or a local Ollama model.
Code
Set model by 3 ways
1. OpenAI Compatible Endpoints
By Default it uses OPENAI_BASE_URL https://api.openai.com/v1
2. Litellm Compatible model names (eg: gemini/gemini-1.5-flash-8b)
3. Litellm Compatible Configuration
Advanced Configuration (Litellm Support)
This uses Litellm
Setup Environment
Ollama Integration
Ollama Integration
Groq Integration
Groq Integration
Google Gemini
Google Gemini
Jan AI Integration
Jan AI Integration
LM Studio Integration
LM Studio Integration
OpenRouter Integration
OpenRouter Integration
Provider Auto-Detection (no-config first run)
When you runpraisonai run without setting --model or a model: key in config.yaml, PraisonAI inspects which supported provider credential is present in your environment and picks a provider-appropriate default — so a user whose only key is ANTHROPIC_API_KEY no longer gets an OpenAI auth error on first run.
| Credential env var | Resolved default model | Base URL |
|---|---|---|
OPENAI_API_KEY | gpt-4o-mini | https://api.openai.com/v1 |
ANTHROPIC_API_KEY | anthropic/claude-3-5-sonnet-latest | https://api.anthropic.com/v1 |
GEMINI_API_KEY | gemini/gemini-1.5-flash | https://generativelanguage.googleapis.com/v1beta |
GOOGLE_API_KEY | google/gemini-1.5-flash | https://generativelanguage.googleapis.com/v1beta |
GROQ_API_KEY | groq/llama-3.3-70b-versatile | https://api.groq.com/openai/v1 |
COHERE_API_KEY | cohere/command-r | https://api.cohere.ai/v1 |
OLLAMA_HOST | ollama/llama3.2 | http://localhost:11434/v1 |
| (none of the above) | gpt-4o-mini | https://api.openai.com/v1 |
The same resolver drives implicit defaults for
praisonai run, praisonai chat, praisonai init scaffolding, praisonai setup, and the bare-praisonai TUI launch — not just run.Primary vs Auxiliary Model
PraisonAI splits your model choice into two knobs:| Knob | What it drives | Configured via |
|---|---|---|
model | The agent’s own reasoning / tool-use turns | Agent(llm=...), [defaults].model |
small_model | Cheap internal calls (session titles, summarisation) | [defaults].small_model |
small_model falls back to model when unset, so single-provider (Anthropic, Ollama, on-prem) setups make zero unexpected third-party calls.
Supported Models for No Code
Example agents.yaml
This uses Multi-Agents with Multi-LLMs.How It Works
The Agent passes yourllm value to the provider resolver, which routes the request to the matching model and returns the response.
Best Practices
Let auto-detection pick the default
Let auto-detection pick the default
Skip
llm= on first runs. PraisonAI resolves a sensible default from whichever provider key is set — see Provider Auto-Detection.Use LiteLLM prefixes for non-OpenAI providers
Use LiteLLM prefixes for non-OpenAI providers
Pass
llm="gemini/gemini-1.5-flash-8b" or llm="anthropic/claude-3-5-sonnet-latest" to target a specific provider model.Keep API keys in the environment
Keep API keys in the environment
Set provider keys in your shell or
.env. Use api_key=None in llm_config so the SDK reads the environment variable.Match model to task
Match model to task
Use a small fast model (
gpt-4o-mini, gemini-1.5-flash) for routing and a larger model only where quality matters.Related
Quick Start
Run your first agent in a few lines.
Tools
Give models real actions with tools.

