# Ask AI for Alerts (BYOK)

Ask AI generates concise triage notes for incoming alerts, outlining probable root causes, severity assessments, and recommended immediate mitigation steps.

## Bring Your Own Key (BYOK) Architecture

OnCallAlert operates on a **zero-telemetry BYOK model**:
- Your server connects directly to your AI provider API using your private API key.
- No incident data, prompts, or telemetry ever route through OnCallAlert servers.
- AI features are included in all paid plans without extra seat fees; you pay only your provider's standard API token rates.

## Supported Providers

| Provider | Base URL | API Key Source | Model Examples |
|---|---|---|---|
| **OpenAI** | Leave empty (default) | OpenAI API Key | `gpt-4o`, `gpt-4o-mini` |
| **Anthropic** | Leave empty (default) | Anthropic Console API Key | `claude-3-5-sonnet-latest`, `claude-3-5-haiku-latest` |
| **Ollama** | `http://localhost:11434/v1` or custom host | Not required | `llama3.1`, `mistral` |
| **OpenAI-Compatible** | e.g. `https://generativelanguage.googleapis.com/v1beta/openai` | Provider API Key | Google Gemini (`models/gemini-1.5-flash`), Groq, DeepSeek |

## Configuration

Navigate to **Admin &rarr; Ask AI**:
1. Toggle **Enable Ask AI** on.
2. Select your **Provider** and input the **Model** identifier.
3. Paste your **API Key** (stored encrypted at rest using `ONCALLALERT_DATA_ENCRYPTION_KEY`).
4. Click **Test Connection**, then **Save**.

## Operational Modes

- **Manual Mode (Default)**: On any incident detail page, click **Ask AI** to request an instant analysis on demand. No provider cost is incurred unless someone explicitly requests a summary.
- **Automatic Mode (Optional)**: Enable **Summarize every new alert automatically** in **Admin &rarr; Ask AI** to trigger analysis as alerts are created. Set **Maximum triages per hour** in **Admin &rarr; Config** to prevent runaway token billing during major alert storms.

## Data Sanitization & Security

Only the alert summary (first 500 characters), alert details (first 4,000 characters), service name, and up to 5 preceding alert titles on that service are transmitted. PII, system secrets, phone numbers, and integration keys are never included in prompts.
