LLM Configuration
This page provides comprehensive documentation for configuring Large Language Models (LLMs) in PraisonAI, including retry mechanisms, timeout settings, custom headers, and advanced optimization options.Environment Variable Precedence
PraisonAI resolves LLM configuration from environment variables using a documented precedence order, ensuring consistent behavior across all components.
Defaults:
- Model:
gpt-4o-mini - Base URL: Provider-specific or
https://api.openai.com/v1 - API Key:
None
Default LLM Timeouts
PraisonAI bounds LLM calls at two layers so an unresponsive provider cannot pin a request indefinitely. See LLM Timeouts for the full guide.Default on direct LLM / Agent(llm=“model”) path
Agents built withpraisonaiagents get a 600 second (10 minute) per-request timeout when timeout is not set.
Default on framework registry / gateway path
Calls dispatched through thepraisonai provider registry (openai, anthropic, google, groq, mistral, bedrock, azure, ollama, xai, deepseek, cohere, together, sagemaker) and gateway providers (openrouter, litellm-proxy, custom-gateway) are bounded by two defaults.
PRAISONAI_LLM_TIMEOUT=abc) logs a warning and falls back to 60.
Behaviour change (PraisonAI PR #5972): an unset
timeout on the direct LLM / Agent(llm=...) path now resolves to 600 s instead of being left to litellm’s 6000 s ceiling — a stuck provider now stops the turn after 10 minutes instead of 100. Pass timeout=None to restore the old behaviour.The registry/gateway defaults were introduced earlier in v4.6.163 (PraisonAI PR #3879). Before that, registry calls had no timeout — a black-holed provider would hold a request open until the OS TCP keepalive gave up (~2 hours on Linux defaults).Core LLM Configuration
Basic Setup
per-call temperature= kwarg > Agent(llm={'temperature': ...}) / Agent(temperature=...) > provider default (temperature omitted from the request).
When temperature is not configured anywhere, the parameter is omitted from the request rather than sent as an explicit None or 1.0. This matters for providers whose default differs from 1.0 — for example reasoning models that reject non-default temperatures (see the note in JS output).
Provider-Specific Configuration
Retry Logic Configuration
Basic Retry Settings
Advanced Retry Logic
Custom Retry Logic Implementation
Timeout Configuration
Timeout Settings
Request-Specific Timeouts
Custom Headers Configuration
Basic Headers
Dynamic Headers
Provider-Specific Headers
Advanced LLM Configuration
Load Balancing
Model Fallback Configuration
See Model Fallback for the full guide.LLMConfig(fallback_models=[...]) — not via raw config dict keys. This covers every agent shape — provider/model strings, custom base_url servers, and model-object LLMs — on sync, async, and streaming turns.
Request Optimization
Rate Limiting Configuration
Complete Configuration Example
Environment Variables
PRAISONAI_LLM_TIMEOUT is the only PRAISONAI_LLM_* variable wired into the SDK today — see Default LLM Timeouts.
Planned (not yet wired)
The variables below are not read by the SDK yet. Exporting them has no effect. They are listed for roadmap visibility only.For a per-call retry override today, pass
num_retries= on the call — the default is 2. For per-call header, timeout, or streaming control, set them inside the llm={...} dict on the Agent (see Core LLM Configuration).Monitoring and Debugging
See Also
- Model Configuration - Supported models and providers
- Agent Configuration - Agent-level LLM settings
- Best Practices - LLM configuration guidelines

