AI Integration
Configure and use AI providers for incident analysis.
Supported Providers
OpenAI
OPENAI_API_KEY=sk-... DEFAULT_AI_PROVIDER=openai
Get API key from https://platform.openai.com/api-keys
Claude (Anthropic)
CLAUDE_API_KEY=sk-ant-... DEFAULT_AI_PROVIDER=claude
Get API key from https://console.anthropic.com
Gemini (Google)
GEMINI_API_KEY=AIzaSy... DEFAULT_AI_PROVIDER=gemini
Get API key from https://makersuite.google.com
Usage Example
from app.services.ai_service import get_ai_service
ai_service = get_ai_service()
# Analyze incident
analysis = await ai_service.analyze_incident(
incident_title="Database Connection Timeout",
description="Connection pool exhausted due to long-running queries"
)
# Get custom response from specific provider
response = await ai_service.get_response(
prompt="Recommend optimization strategies",
provider="claude" # or "openai", "gemini"
)Best Practices
- • Rotate API keys regularly
- • Use environment-specific keys for different environments
- • Monitor API usage and costs
- • Implement rate limiting on your endpoints
- • Cache AI responses when applicable