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
Every LLM call PraisonAI dispatches through LiteLLM — for registry providers (openai, anthropic, google, groq, mistral, bedrock, azure, ollama, xai, deepseek, cohere, together, sagemaker) and gateway providers (openrouter, litellm-proxy, custom-gateway) — is bounded by two defaults so an unresponsive provider cannot pin a request coroutine or a worker thread indefinitely.
PRAISONAI_LLM_TIMEOUT=abc) logs a warning and falls back to 60.
Introduced in v4.6.163 (PraisonAI PR #3879). Before this release, LLM calls had no timeout — a black-holed provider would hold a request coroutine open until the OS TCP keepalive gave up (~2 hours on Linux defaults). If you were setting
timeout= at every call site as a workaround, you no longer need to.Core LLM Configuration
Basic Setup
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.
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

