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.| Variable | Purpose | Precedence |
|---|---|---|
MODEL_NAME | Model name (highest priority) | 1 |
OPENAI_MODEL_NAME | Model name (legacy compat) | 2 |
OPENAI_BASE_URL | LLM endpoint URL (highest priority) | 1 |
OPENAI_API_BASE | LLM endpoint URL (legacy compat) | 2 |
OLLAMA_API_BASE | Ollama endpoint URL | 3 |
ANTHROPIC_API_KEY | Anthropic API key (for anthropic/* models) | — |
GOOGLE_API_KEY | Google API key (for google/* models) | — |
GEMINI_API_KEY | Gemini API key (for gemini/* models) | — |
GROQ_API_KEY | Groq API key (for groq/* models) | — |
COHERE_API_KEY | Cohere API key (for cohere/* models) | — |
OPENROUTER_API_KEY | OpenRouter API key (for openrouter/* models) | — |
OLLAMA_API_KEY | Ollama API key (for ollama/* models) | — |
OPENAI_API_KEY | OpenAI API key (for OpenAI models and fallback) | — |
- Model:
gpt-4o-mini - Base URL: Provider-specific or
https://api.openai.com/v1 - API Key:
None
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
Request Optimization
Rate Limiting Configuration
Complete Configuration Example
Environment Variables
Monitoring and Debugging
See Also
- Model Configuration - Supported models and providers
- Agent Configuration - Agent-level LLM settings
- Best Practices - LLM configuration guidelines

