> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mka1.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Production quality monitoring

> Sample live traffic opt-in, track quality scores against baselines, and raise drift alerts with privacy, cost, and notification controls.

Production quality monitors continuously score a bounded sample of live Responses and Chat Completions traffic. Each monitor builds a quality baseline, evaluates rolling score windows, and raises tenant-visible drift alerts when quality drops past your configured threshold.

> [!NOTE]
>
> Live quality monitors are available through the REST API and the console under **Evals → Monitoring**. Typed SDK and CLI helpers follow automatically once your cluster publishes the updated OpenAPI specification.

## Before you start

* **Opt-in only.** No live traffic is sampled until you create and enable a monitor.
* **Scopes.** Reading monitors, samples, and drift alerts requires `read:evals`. Creating, updating, evaluating, recalibrating, acknowledging, resolving, and deleting monitors requires `write:evals`.
* **Role requirements.** Creating or modifying live traffic monitors (`team` or `org` scope) requires an organization owner or admin acting directly (not via `X-On-Behalf-Of`), because monitors sample traffic across the team or organization.

## Built-in evaluators and custom rubrics

Monitors use reference-free evaluators designed for live traffic where ground-truth labels do not exist. List the catalog with `GET /api/v1/llm/evals/monitors/evaluators`:

| Evaluator ID | What it measures |
| :- | :- |
| `helpfulness_relevance` | Directly addresses the user request with accurate, useful information. |
| `coherence_clarity` | Clear, well-structured, non-repetitive writing in the user's language. |
| `instruction_following` | Follows explicit user and system instructions, constraints, and formats. |
| `groundedness` | Stays faithful to retrieved context without unsupported claims (reuses live groundedness signals when present). |
| `safety_compliance` | Refuses harmful or policy-violating content cleanly (short-circuits guardrail-blocked responses without calling a judge). |

You can also attach `custom_rubric` evaluators with a domain-specific 0.0–1.0 scoring rubric. When a monitor enables multiple LLM-judged evaluators, the worker batches them into one structured judge call per sample.

## Create a quality monitor

Create a monitor targeting a saved agent, a model, or all matching traffic in the team or organization.

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --data '{
    "name": "Support agent live quality",
    "scope": "team",
    "target_agent_id": "agent_abc123",
    "api_surfaces": ["responses"],
    "evaluators": [
      { "kind": "builtin", "id": "helpfulness_relevance", "version": "v1" },
      { "kind": "builtin", "id": "instruction_following", "version": "v1" }
    ],
    "judge_model": "meetkai:functionary-urdu-mini-pak",
    "sample_rate": 0.1,
    "max_samples_per_day": 200,
    "max_daily_cost_usd": 5.0,
    "redact_secrets": true,
    "payload_retention": "scores_only",
    "retention_days": 30,
    "baseline_mode": "auto",
    "baseline_min_samples": 20,
    "window_minutes": 1440,
    "min_samples": 10,
    "max_drop": 0.15,
    "min_score": 0.7,
    "cooldown_minutes": 60,
    "notify_on_drift": true,
    "enabled": true
  }'
```

Key configuration fields:

* **Targeting.** Filter by `target_agent_id`, `target_model`, and `api_surfaces` (`responses`, `chat_completions`, or both).
* **Sampling and cost caps.** `sample_rate` selects a deterministic fraction of eligible requests without blocking the live response path. `max_samples_per_day`, `max_daily_cost_usd`, and `max_judge_tokens_per_day` bound daily judge spend, and `max_input_chars` / `max_output_chars` bound each sample payload.
* **Baselines.** `baseline_mode: "auto"` calibrates the baseline mean and standard deviation once `baseline_min_samples` are scored. `baseline_mode: "fixed"` starts enforcing immediately against `fixed_baseline_score`.
* **Drift thresholds.** An alert triggers when a rolling `window_minutes` window has at least `min_samples` scored samples and either drops by at least `max_drop` from the baseline (`drop_from_baseline`) or falls below `min_score` (`below_floor`). `cooldown_minutes` prevents duplicate notifications while a metric remains drifted. Active alerts auto-resolve once the rolling score recovers above the threshold with hysteresis.

## Privacy and residency controls

Quality monitoring applies structural privacy controls at capture, judging, storage, and alerting:

* **`store: false` exclusion (Responses).** Any Responses request sent with `store: false` is unconditionally excluded from live sampling. Chat Completions does not carry a `store` flag, so all matching Chat Completions requests on a monitored surface are eligible.
* **Secret redaction.** With `redact_secrets: true` (the default), the gateway runs its secret redactor over captured input and output text before sending samples to the judge or writing previews, masking credentials, bearer tokens, and API keys.
* **Scores-only retention.** With `payload_retention: "scores_only"` (the default), input and output text is cleared immediately after scoring, leaving only numeric scores, judge rationales, and usage metadata. Set `payload_retention: "redacted_preview"` if you want to inspect bounded previews in the console until `retention_days` expires. Deleting a stored response immediately clears captured previews and judge payloads for that response.
* **Judge model pinning.** Setting `judge_model` pins judging to that exact model ID and disables cross-provider fallback. Leave `judge_model` unset to use your organization's default analyzer model.
* **Metadata-only alerts.** Drift alert events include only monitor IDs, metric IDs, scores, deltas, thresholds, and window timestamps—never raw prompts or outputs.

## Evaluate on demand and inspect results

Background scoring runs continuously on the eval worker. You can also trigger an immediate scoring and drift-evaluation pass:

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id>/evaluate \
  --request POST \
  --header 'Authorization: Bearer <mka1-api-key>'
```

Retrieve monitor status, per-metric baselines, bucketed score trends, and recent drift alerts:

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id> \
  --header 'Authorization: Bearer <mka1-api-key>'
```

Inspect recently sampled interactions and scores:

```bash Bash theme={null}
curl 'https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id>/samples?limit=25' \
  --header 'Authorization: Bearer <mka1-api-key>'
```

Reset the baseline after an intentional prompt or model change. Auto recalibration clears the baseline so it calibrates fresh from subsequent scored samples and resolves both active and acknowledged drift alerts for the monitor:

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id>/recalibrate \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --data '{ "mode": "auto" }'
```

## Drift alerts and notification channels

Every drift breach is stored on the monitor and visible in **Evals → Monitoring** and via `GET /api/v1/llm/evals/monitors/alerts`. Acknowledge or resolve an alert through the console or API:

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id>/alerts/<alert-id> \
  --request PATCH \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --data '{ "status": "acknowledged" }'
```

When `notify_on_drift` is `true`, the gateway also emits a `quality.drift_detected` audit alert event. Subscribe to `quality.drift_detected` in **Admin → Alerts** to route drift alerts to tenant Webhook, Email, or ITSM rules scoped to your organization or team.

## Pause, resume, or delete a monitor

Pause sampling without deleting historical scores or alerts:

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id> \
  --request PATCH \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --data '{ "enabled": false }'
```

Remove a monitor from active monitoring (soft-deletes the monitor, stops new sampling as caches expire, skips pending samples, and clears stored sample previews):

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/llm/evals/monitors/<monitor-id> \
  --request DELETE \
  --header 'Authorization: Bearer <mka1-api-key>'
```

## What to read next

* [Evaluations](https://docs.mka1.com/docs/evals.md) covers offline task suites and Python graders for pre-release testing.
* [Schedule eval runs](https://docs.mka1.com/docs/eval-schedules.md) covers recurring scheduled suite runs.
* [Guardrails](https://docs.mka1.com/docs/guardrails.md) covers real-time inline input and output blocking policies.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.