---
title: "Analyze recorded task durations, P50, P95 and retries"
method: POST
path: "/api/v1/latency"
---

# Analyze recorded task durations, P50, P95 and retries

`POST /api/v1/latency`

## Request

- Base URL: `https://alpnai.com`
- URL: `https://alpnai.com/api/v1/latency`
- 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
    - `measurement` 'summed_recorded_attempt_durations_per_task', required
    - `percentile_method` 'nearest_rank', required
    - `groups` object[], required
      - `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
      - `tasks` integer, required
      - `recorded_attempts` integer, required
      - `retry_attempts` integer, required
      - `duration_coverage` number, required
      - `p50_ms` number, nullable, required
      - `p95_ms` number, nullable, required
      - `max_ms` number, nullable, required
      - `threshold_ms` number, nullable, required
      - `within_p95_threshold` boolean, nullable, 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)
