Real API Key Testing
PraisonAI Agents includes a gated test harness for running integration tests with real API keys. Tests are skipped by default and only run when explicitly enabled.Enabling Real API Tests
Set the environment variable to enable real API tests:Test Categories
Agent Tests
Basic agent functionality with real LLM calls:Tool Tests
Agent with tool execution:LiteAgent Tests
Lite package with real API:Supported Providers
OpenAI
Anthropic
Google (Gemini)
Writing Real API Tests
Test Structure
Best Practices
- Minimize tokens - Use short prompts and low max_tokens
- Use fast models - Prefer gpt-4o-mini over gpt-4
- Set timeouts - Avoid hanging tests
- Clean up resources - Close connections properly
CI/CD Integration
GitHub Actions
Local Testing
Security
- Never commit API keys - Use environment variables
- Use secrets in CI - Store keys in GitHub Secrets
- Rotate keys regularly - Especially after exposure
- Limit key permissions - Use restricted API keys for testing

