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
1
Install Package
Install required packages:
2
Setup Environment
3
Create Agent
Create
app.py: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.
Precedence: the first credential in the table that is set wins. If multiple provider keys are set, the one listed first takes effect.
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.Keyless local-first fallback (no env vars set)
If no cloud provider key is set and a local OpenAI-compatible endpoint answers onhttp://127.0.0.1:11434 (or wherever OPENAI_BASE_URL / OLLAMA_HOST points), PraisonAI uses that local server as the zero-config default — the first praisonai run "..." just works before you configure anything.
--model <name>on the command line.- Any cloud provider key from the table above.
- A reachable local endpoint at
OPENAI_BASE_URL→OLLAMA_HOST→http://127.0.0.1:11434. gpt-4o-minifallback.
Detection is timeout-bounded (~150 ms) and cached briefly, so the first-run hot path stays fast when nothing is listening. Cloud keys always win — the local probe is skipped entirely when any cloud key is set.
See Local Models for the full guide.
No cloud key at all? If Ollama (or any OpenAI-compatible local server) is running, PraisonAI will use it — no API key and no config. See Keyless Local-First Run.
Primary vs Auxiliary Model
PraisonAI splits your model choice into two knobs:small_model falls back to model when unset, so single-provider (Anthropic, Ollama, on-prem) setups make zero unexpected third-party calls — the auxiliary calls (titles, compaction, guardrails) all stay on your configured provider.
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.

