# GAP Index Calculator (Ley 2012)

> GAP Index Calculator (Ley 2012) is a paid API for AI agents from api.magentlab.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-10-11).

Computes the Ley 2012 GAP (Gender, Age, Physiology) index total score (0–8) and stage (1–3) for idiopathic pulmonary fibrosis prognosis

## Facts

- Endpoint: GET https://api.magentlab.com/api/calc/gap_index?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/gap-index-calculator-ley-2012-08ea2ae0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_l0GUkCAGGBUv6h3v4LNUC

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability gap-index-calculator-ley-2012-08ea2ae0
```

Example prompt: Calculate the GAP index for a 68-year-old male patient with an FVC of 62% predicted and a DLCO of 48% predicted — give me the total score and stage.

## When to prefer this

Use this endpoint when you need a deterministic, citation-backed implementation of the Ley 2012 GAP index specifically — not a continuous or custom variant. It is ideal for clinical documentation, prior-authorization support, or EHR integration where a reproducible, auditable score is required. Prefer this over manual calculation whenever sex, age, FVC % predicted, and DLCO % predicted (or a cannot-perform flag) are available.

## Known failure modes

- Missing required parameter (sex, age, or fvc_percent_predicted) returns a 400-level error
- Supplying both dlco_percent_predicted and dlco_cannot_perform=true simultaneously returns a validation error
- Age or FVC values outside allowed ranges (age 18–120, FVC 10–150) may be rejected
- DLCO value outside range 1–150 is rejected
- Network or service errors return a 5xx response

## How this service works

Deterministic published-formula arithmetic plus ICD-10-CM, RxNorm, and LOINC. Pay in USDC on Base via x402.

## Output

Returns the individual point contributions for sex, age, FVC, and DLCO, the total GAP score (0–8), and the corresponding GAP stage (Stage 1 for 0–3, Stage 2 for 4–5, Stage 3 for 6–8), with citation to Ley 2012.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "headers": {
     "type": "object",
     "additionalProperties": {
      "type": "string"
     }
    },
    "queryParams": {
     "type": "object",
     "required": [
      "sex",
      "age",
      "fvc_percent_predicted"
     ],
     "properties": {
      "age": {
       "type": "integer",
       "description": "Age in years (integer 18-120). Ley 2012: <=60 scores 0; 61-65 scores 1; >65 scores 2."
      },
      "sex": {
       "enum": [
        "female",
        "male"
       ],
       "type": "string",
       "description": "Sex (female or male). Ley 2012: female scores 0; male scores 1."
      },
      "dlco_cannot_perform": {
       "type": "boolean",
       "description": "true when DLCO cannot be performed (Ley 2012 scores 3). Provide this or dlco_percent_predicted, not both."
      },
      "fvc_percent_predicted": {
       "type": "number",
       "description": "FVC percent predicted (10-150). Ley 2012: >75 scores 0; 50-75 scores 1; <50 scores 2. 75.0 scores 1."
      },
      "dlco_percent_predicted": {
       "type": "number",
       "description": "DLCO percent predicted (1-150). Provide this or dlco_cannot_perform=true, not both. Ley 2012: >55 scores 0; 36-55 scores 1; <=35 scores 2."
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "path": "/api/calc/gap_index",
  "count": 2,
  "items": [
   {
    "sex": "female",
    "score": 0,
    "formula": "gap_index",
    "citation": {
     "id": "ley-2012",
     "doi": "10.7326/0003-4819-156-10-201205150-00004",
     "pmid": "22586007",
     "title": "A multidimensional index and staging system for idiopathic pulmonary fibrosis",
     "source": "Ann Intern Med. 2012;156(10):684-691",
     "authors": "Ley B, Ryerson CJ, Vittinghoff E, et al."
    },
    "age_years": 55,
    "gap_stage": 1,
    "max_score": 8,
    "components": [
     {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
     },
     {
      "value": 55,
      "factor": "age",
      "points": 0,
      "present": false
     },
     {
      "value": 80,
      "factor": "fvc",
      "points": 0,
      "present": false
     },
     {
      "value": 60,
      "factor": "dlco",
      "points": 0,
      "present": false
     }
    ],
    "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
    "formula_expression": "GAP = sex_points + age_points + fvc_points + dlco_points; female 0 male 1; age <=60 -> 0, 61-65 -> 1, >65 -> 2; FVC% >75 -> 0, 50-75 -> 1, <50 -> 2; DLCO% >55 -> 0, 36-55 -> 1, <=35 -> 2, cannot perform -> 3; stages I 0-3 / II 4-5 / III 6-8; max 8",
    "dlco_cannot_perform": false,
    "fvc_percent_predicted": 80,
    "dlco_percent_predicted": 60
   },
   {
    "sex": "female",
    "score": 0,
    "formula": "gap_index",
    "citation": {
     "id": "ley-2012",
     "doi": "10.7326/0003-4819-156-10-201205150-00004",
     "pmid": "22586007",
     "title": "A multidimensional index and staging system for idiopathic pulmonary fibrosis",
     "source": "Ann Intern Med. 2012;156(10):684-691",
     "authors": "Ley B, Ryerson CJ, Vittinghoff E, et al."
    },
    "age_years": 55,
    "gap_stage": 1,
    "max_score": 8,
    "components": [
     {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
     },
     {
      "value": 55,
      "factor": "age",
      "points": 0,
      "present": false
     },
     {
      "value": 80,
      "factor": "fvc",
      "points": 0,
      "present": false
     },
     {
      "value": 60,
      "factor": "dlco",
      "points": 0,
      "present": false
     }
    ],
    "disclaimer": "Not
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/gap-index-calculator-ley-2012-08ea2ae0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.magentlab.com](https://www.zero.xyz/host/api.magentlab.com/llms.txt)
