Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
# ─── AiSOC LiteLLM gateway config (issue #478) ──────────────────────────────────
#
# LiteLLM is the single entry point for every *live* LLM call AiSOC makes. AiSOC
# asks for a logical **task alias** (the `model_name` values below); this file —
# and only this file — decides which real provider/model each alias resolves to.
# Operators re-point a task to a different local or hosted model here, with no
# AiSOC code change and no redeploy of the app services.
#
# AiSOC task ──▶ alias (e.g. "aisoc-triage") ──▶ LiteLLM ──▶ real model
#
# The aliases below mirror AiSOC's distinct LLM workloads. Keep this set in sync
# with the role pins in services/agents/app/llm/model_pins.py — the agents test
# `test_litellm_config.py` asserts they match.
#
# Every alias resolves its credential from the process env (os.environ/...), so
# no secret is ever written to this file. Point AiSOC at the gateway by setting
# (see .env.example):
# OPENAI_BASE_URL=http://litellm:4000/v1
# OPENAI_API_KEY=$LITELLM_MASTER_KEY
#
# ── WHICH MODEL ANSWERS, AND HOW TO CHANGE IT ─────────────────────────────────
#
# Every alias below takes its backend from the environment rather than naming
# one inline, and docker-compose.yml supplies the defaults. Out of the box those
# defaults point at the **Ollama service bundled in CORE**, running a pinned
# ~2 GB llama3.2:3b-instruct-q4_K_M sized for CPU-only inference in 8 GB of RAM.
# That is why a default `make up` can do real AI triage with no API key and no
# account: the local model is the floor, not a stub.
#
# It is a 3B quantized model. It is genuinely doing the work — real tokens, real
# cost accounting, real generated text — and it is not as good as a frontier
# model. **To upgrade**, put a provider key in `.env` and set the two model
# variables beside it:
#
# OPENAI_API_KEY=sk-...
# AISOC_LLM_MODEL_FAST=openai/gpt-4o-mini
# AISOC_LLM_MODEL_DEEP=openai/gpt-4o
# AISOC_LLM_API_BASE=
#
# then `make up` again. No code change, no profile change, no edit to this file.
# Air-gapped deployments keep the defaults and never set a key.
#
# When no live model is reachable at all AiSOC still degrades to its
# deterministic offline path (the `deterministic` floor in model_pins.py) and
# reports zero model calls and zero tokens rather than pretending to triage.
model_list:
# ── Auto-triage: high volume, cheap+fast. ─────────────────────────────────────
- model_name: aisoc-triage
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Recon / enrichment reasoning. ─────────────────────────────────────────────
- model_name: aisoc-recon
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Deep investigation: the multi-step reasoning path — worth a stronger model.
- model_name: aisoc-investigation
litellm_params:
model: os.environ/AISOC_LLM_MODEL_DEEP
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Contextual copilot: interactive analyst Q&A. ──────────────────────────────
- model_name: aisoc-copilot
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Summaries: alert/incident condensation. ───────────────────────────────────
- model_name: aisoc-summary
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Reports: analyst-facing write-ups — quality over cost. ────────────────────
- model_name: aisoc-report
litellm_params:
model: os.environ/AISOC_LLM_MODEL_DEEP
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Natural-language generation: NL→query / NL→detection translation. ─────────
- model_name: aisoc-nl
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# Gap-closure Phase 8.3. The hunting agent turns a natural-language
# hypothesis into a structured plan over a closed field vocabulary. It emits
# JSON against a fixed schema rather than prose, so the fast model is the
# right default; a deployment wanting more careful field selection points
# AISOC_LLM_MODEL at something larger.
- model_name: aisoc-hunt
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# Parity 2.5. The detection-tuning loop rewrites a Sigma rule from an
# analyst note and the fields of a misfiring alert. It hardcoded
# `gpt-4o-mini`, so on CORE it reached LiteLLM, which knows the `aisoc-*`
# aliases and not that id, and every call 400'd with `Invalid model name`
# and fell through to the deterministic path. Fast model: the output is
# JSON against a fixed schema rather than reasoning.
- model_name: aisoc-detection
litellm_params:
model: os.environ/AISOC_LLM_MODEL_FAST
api_base: os.environ/AISOC_LLM_API_BASE
api_key: os.environ/OPENAI_API_KEY
# ── Other backends ────────────────────────────────────────────────────────────
# The two variables above take any LiteLLM model string, so most swaps need no
# edit here at all:
#
# self-hosted vLLM AISOC_LLM_MODEL_DEEP=openai/Qwen2.5-32B-Instruct
# AISOC_LLM_API_BASE=http://vllm:8000/v1
# Anthropic AISOC_LLM_MODEL_DEEP=anthropic/claude-3-5-sonnet-latest
# ANTHROPIC_API_KEY=... (and clear AISOC_LLM_API_BASE)
# a bigger local AISOC_LLM_MODEL_DEEP=ollama_chat/llama3.1:8b
# (pull it first: docker compose exec ollama ollama pull llama3.1:8b)
#
# On "a bigger local": pick by measurement, and mind the generation. Graded
# on the 72-item balanced verdict corpus, five local models came out:
#
# llama3.1:8b-instruct-q4_K_M 0.357 balanced ECE 0.349 <- best
# llama3.2:3b-instruct-q4_K_M 0.285 balanced ECE 0.442 <- CPU default
# llama3:8b 0.279 balanced ECE 0.421
# qwen2.5:7b-instruct-q4_K_M 0.260 balanced ECE 0.594
# mistral:7b-instruct-v0.3 0.210 balanced ECE 0.366
#
# So "8B" is not the useful unit: llama3.1:8b leads and the previous-
# generation llama3:8b scores below the 3B it would replace. The GPU and
# host-LLM overlays already default to the winner; this line is for anyone
# routing a single role by hand.
#
# Two caveats that outrank the ranking. A constant answer scores 0.250, so
# every row here is far closer to chance than to useful. And auto-close
# precision is poor across all five (0.091-0.571 on 7-37 candidates), so
# nothing measured supports autonomous closure on any of them. Re-grade
# with `scripts/run_verdict_eval.py` before moving a deployment.
#
# Per-alias divergence — a different model for one workload only — is the case
# that does need an edit: replace that alias's `os.environ/...` with a literal.
# ── Gateway behaviour ─────────────────────────────────────────────────────────
litellm_settings:
# Silently drop provider-specific params a given backend doesn't support, so
# the same AiSOC request body works across OpenAI / Ollama / vLLM / Anthropic.
drop_params: true
# Per-request latency, tokens, cost, errors, retries and fallbacks are exported
# on GET /metrics for Prometheus (scraped as job `aisoc-litellm`). This is the
# centralized observability layer that complements the Investigation Ledger.
callbacks: ["prometheus"]
# Prometheus scrapes /metrics with no Authorization header; LiteLLM otherwise
# requires auth on that endpoint (and the auth path needs the DB layer). Allow
# unauthenticated scrapes so the `aisoc-litellm` job actually collects. The
# port is bound to 127.0.0.1 in compose, so /metrics isn't publicly exposed.
require_auth_for_metrics_endpoint: false
# Never wait forever on a stalled provider — fall through to AiSOC's own
# deterministic path instead of hanging the alert drawer.
#
# This read `request_timeout: 60`, the one bare literal in a file where every
# other value resolves from the environment, so raising it meant editing a
# mounted file and rebuilding. 60s is not a universal number: the bundled 3B
# model doing CPU-only inference on a long generation can exceed it, and
# every call then times out while the Settings panel still reports the
# provider Live (issue #1241). The default is unchanged — the knob is new.
#
# Measured against `ghcr.io/berriai/litellm:v1.102.1` (then served by the
# since-deleted `main-stable` tag), because two
# plausible-looking alternatives do not work:
#
# * LiteLLM's own `REQUEST_TIMEOUT` environment variable is read and
# float-coerced in `litellm/constants.py`, but it does **not** reach the
# proxy's router path: a gateway started with `REQUEST_TIMEOUT=5` and no
# key here was still waiting on a blackholed provider after 200s.
# * This key *does* reach it. `get_secret` resolves `os.environ/...` to a
# string (it coerces only booleans), LiteLLM assigns that straight onto
# `litellm.request_timeout`, and the value lands: with the variable at 3,
# the gateway answered 408 with `timeout value=3.0, time taken=3.0`.
#
# The variable must therefore be SET. `get_secret` returns None for an unset
# one, and a gateway in that state answers 200 on `/health/liveliness` while
# failing every completion with `float() argument must be a string or a real
# number, not 'NoneType'`. `docker-compose.yml` supplies the default, and
# `test_litellm_config.py` fails if that default is ever removed — the config
# is already hard-dependent on its environment in the same way (with
# `AISOC_LLM_MODEL_FAST` unset this file does not start at all).
request_timeout: os.environ/AISOC_LITELLM_REQUEST_TIMEOUT
# ── Router: retries + cross-model fallbacks ───────────────────────────────────
# model_pins.py documents that "the LiteLLM gateway owns any model-level
# fallback" — this block makes that real. Without it each alias had exactly one
# model and zero failover, so a single provider blip dropped straight to the
# offline deterministic floor.
router_settings:
# Retry a transient failure (rate limit / 5xx / timeout) on the same alias
# before falling back.
#
# A literal on purpose, and not environment-driven like the timeout above.
# LiteLLM hands `router_settings` straight to `Router.__init__` with no type
# coercion (`router_params[k] = v`), and the retry path evaluates
# `num_retries > 0`, which raises `TypeError` against a string at precisely
# the moment a retry is needed. The knob that matters for slow hardware is
# the timeout, and that one is environment-driven.
num_retries: 2
# Cross-model failover: if an alias's primary model keeps failing, route the
# request to an adjacent/cheaper alias so quality degrades gracefully instead
# of dropping to heuristics. Keys are the requested alias; values are ordered
# fallbacks.
fallbacks:
- aisoc-investigation: ["aisoc-triage"]
- aisoc-report: ["aisoc-summary"]
- aisoc-recon: ["aisoc-triage"]
- aisoc-copilot: ["aisoc-triage"]
- aisoc-nl: ["aisoc-triage"]
# Trip a per-model cooldown after repeated failures so a wedged provider stops
# being tried for a short window.
allowed_fails: 3
cooldown_time: 30
general_settings:
# Clients (the AiSOC services) authenticate to the gateway with this key. Set
# it in the environment; AiSOC sends it as its OPENAI_API_KEY when
# OPENAI_BASE_URL points here. Never commit a real key.
master_key: os.environ/LITELLM_MASTER_KEY