---
title: "Check quality, cost and recorded latency thresholds"
method: POST
path: "/api/v1/quality-gate"
---

# Check quality, cost and recorded latency thresholds

`POST /api/v1/quality-gate`

## Request

- Base URL: `https://alpnai.com`
- URL: `https://alpnai.com/api/v1/quality-gate`
- Auth: HTTP bearer

## Request body

- object: Recorded attempts, not prompts or secrets. Identical rows count as separate attempts. All three analysis tools accept this same input. The runtime validator additionally enforces six-decimal micro-USD precision, the same task_id belonging to one workflow, one workflow when monthlyTasks is given, and UTF-16 length limits. HTTP body limit: 512000 UTF-8 bytes.
  - `runs` object[], required
    - `task_id` string, required: Nonempty, no control characters or surrounding whitespace. The engine additionally enforces at most 128 UTF-16 code units.
    - `workflow` string, required: Nonempty, no control characters or surrounding whitespace. The engine additionally enforces at most 80 UTF-16 code units.
    - `variant` 'baseline' | 'candidate', required
    - `cost_usd` number, required: USD cost of this attempt. At most six decimal places; the engine verifies whole micro-USD using floating-point tolerance. No multipleOf keyword is used, to avoid rejecting valid JSON decimals.
    - `success` boolean, required
    - `latency_ms` number: Recorded attempt duration in milliseconds; decimals are accepted. Omit if not measured.
  - `config` object
    - `minSamples` integer
    - `minSuccessRate` number
    - `maxSuccessRateDrop` number
    - `maxP95LatencyMs` number
    - `monthlyTasks` integer: Baseline logical tasks launched per month; the engine requires exactly one workflow if supplied.

## Response `200`

Analysis computed from supplied traces; no payment, no application storage.

- object
  - `mode` 'free_audit', required
  - `payment_required` false, required
  - `persisted` false, required
  - `data` object, required
    - `schema_version` '1.0.0', required
    - `config` object, required
      - `minSamples` integer, required
      - `minSuccessRate` number, required
      - `maxSuccessRateDrop` number, required
      - `maxP95LatencyMs` number
      - `monthlyTasks` integer: Baseline logical tasks launched per month; the engine requires exactly one workflow if supplied.
    - `workflows` object[], required
      - `workflow` string, required: Nonempty, no control characters or surrounding whitespace. The engine additionally enforces at most 80 UTF-16 code units.
      - `comparison` object, required
        - `matched_task_ids` integer, required
        - `baseline_only_tasks` integer, required
        - `candidate_only_tasks` integer, required
        - `same_task_set` boolean, required
      - `gates` object, required
        - `both_variants` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `minimum_distinct_tasks_per_variant` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `same_task_set` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `observed_success_rate` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `recorded_latency` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `lower_cost_per_successful_task` 'pass' | 'fail' | 'unknown' | 'not_requested', required
        - `experimental_bias_control` 'unknown', required
      - `decision` 'missing_comparison' | 'collect_more_data' | 'quality_regression' | 'latency_data_required' | 'latency_regression' | 'no_economic_advantage' | 'candidate_for_controlled_trial', required
      - `baseline_success` number, nullable, required
      - `candidate_success` number, nullable, required
      - `automatic_deployment_authorized` false, required

## Other responses

- `400`: Invalid input
- `401`: Active test agent key required
- `413`: 512000-byte request limit exceeded

---

[API](https://skmtc.dev/alpnai/apis/alpnai-agent-api.md) · [All operations](https://skmtc.dev/alpnai/apis/alpnai-agent-api/llms.txt) · [OpenAPI document](https://skmtc.dev/alpnai/apis/alpnai-agent-api/revisions/ab20b858b8d4?raw)
