# Kidney Failure Risk Equation

KFRE

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/kfre`
HTML: https://magentlab.com/docs/kfre
Markdown: https://magentlab.com/docs/kfre.md

Not a medical device. Not a diagnosis, dose, or listing recommendation.

## What it computes

Compute 2-year and 5-year risk of kidney failure (dialysis or preemptive transplant) from the Tangri 2011 4-variable Kidney Failure Risk Equation (age, sex, eGFR, urine ACR).

## When to use

When an agent already has age, male/female, a caller-supplied eGFR, and urine ACR in mg/g and needs that paper's 4-variable 2- and 5-year risks. Not a dialysis or transplant order, not CKD-EPI, and not the 8-variable or 2016 country-recalibrated equations.

## When not to use

- Not a medical device. Not a dialysis or transplant order or referral threshold. magent does not assay creatinine or ACR and does not compute CKD-EPI eGFR.
- Tangri 2011 4-variable model only (age, sex, eGFR, urine ACR). Does not ship the 8-variable model (calcium, phosphate, bicarbonate, albumin).
- Does not apply Tangri 2016 country recalibrations or North-America vs non-North-America S0 splits. No race input.
- Derivation was referred CKD stages 3-5 (eGFR about 10-59 mL/min/1.73 m2). Age 18-90 is a magent adult clamp. Caller supplies eGFR; magent does not estimate it.
- Emits 2-year and 5-year risk percents. Does not assign a named risk class; Tangri 2011 printed stage-specific NRI cutoffs, not a class field on this equation.

## Formula

```
LP = -0.2201*(age_years/10 - 7.036) + 0.2467*(male - 0.5642) - 0.5567*(egfr_ml_min/5 - 7.222) + 0.4510*(ln(acr_mg_g) - 5.137); 2-year risk = 1 - 0.9750^exp(LP); 5-year risk = 1 - 0.9240^exp(LP); Tangri 2011 4-variable only; male is 1 if true else 0; ACR mg/g natural log; caller supplies eGFR; not 8-variable; not Tangri 2016 country S0; no race
```

## Citation

[A predictive model for progression of chronic kidney disease to kidney failure](https://doi.org/10.1001/jama.2011.451)
Tangri N, Stevens LA, Griffith J, Tighiouart H, Djurdjev O, Naimark D, Levin A, Levey AS
JAMA. 2011;305(15):1553-1559
DOI: [10.1001/jama.2011.451](https://doi.org/10.1001/jama.2011.451)

## Worked example

### Age 55, male, eGFR 30, ACR 300 mg/g (CKD 3-5 range)

Given: `acr_mg_g=300, age_years=55, egfr_ml_min=30, male=true`

1. age term = -0.2201 * (55/10 - 7.036) = 0.3380736
2. male term = 0.2467 * (1 - 0.5642) = 0.10751186
3. eGFR term = -0.5567 * (30/5 - 7.222) = 0.6802874
4. ln(300) = 5.7037824747; ACR term = 0.4510 * (5.7037824747 - 5.137) = 0.2556189
5. LP = 1.38149176 → 1.3815
6. 2-year = 1 - 0.9750^exp(LP) → 9.6%
7. 5-year = 1 - 0.9240^exp(LP) → 27.0%


## Also searched as

- Kidney Failure Risk Equation
- KFRE
- Tangri 2011 KFRE
- 4-variable KFRE
- kidney failure risk
- CKD kidney failure risk
- Tangri 4-variable

## Parameters

- `age_years` (integer, required): Age in years (18-90, magent clamp). Tangri 2011 4-variable model uses age as a continuous predictor (per 10 years, centered at 7.036). Adult CKD 3-5 derivation.
- `male` (boolean, required): true if male, false if female. Enters the linear predictor as 1 or 0 (centered at 0.5642). No race coefficient.
- `egfr_ml_min` (number, required): Caller-supplied eGFR in mL/min/1.73 m2 (1-150, magent clamp; must be positive). Tangri 2011 derivation was CKD stages 3-5. magent does not compute CKD-EPI eGFR and does not assay creatinine.
- `acr_mg_g` (number, required): Urine albumin-to-creatinine ratio in mg/g (0.1-10000, magent clamp; must be positive). Enters as natural log, centered at 5.137. magent does not assay ACR and does not convert from mg/mmol.

## Bulk (POST)

POST the same path with a JSON items array. The first item is the GET unit; each additional item is $0.002. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/kfre`
Max items: 25
Price: unit_amount + extra_item_amount * (n - 1) (unit 5000 atomic, extra 2000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- POST of 1 item costs the same as GET. Lists longer than 25: chunk into multiple POSTs. Extra items still execute; do not pad dummy rows.
- The first invalid item fails the whole request (index in the 400 JSON). You are not charged.
- HTTP 200 is {count, path, items}. Each items[i] is the GET 200 body for that row.
- Catalog misses (empty matches, found=false) stay paid 200s inside that slot.
- x402 resource URL is this path plus n and body_sha256. Browsers that prefer text/html get the same paywall as GET; Pay retries POST with the same items.

Example request:

```json
{
  "items": [
    {
      "acr_mg_g": "300",
      "age_years": "55",
      "egfr_ml_min": "30",
      "male": "true"
    },
    {
      "acr_mg_g": "300",
      "age_years": "55",
      "egfr_ml_min": "30",
      "male": "true"
    }
  ]
}
```

Human paywall (two-item fixture): https://api.magentlab.com/paywall/bulk/kfre

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/kfre",
  "items": [
    {
      "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.",
      "citation": {
        "authors": "Tangri N, Stevens LA, Griffith J, Tighiouart H, Djurdjev O, Naimark D, Levin A, Levey AS",
        "doi": "10.1001/jama.2011.451",
        "id": "tangri-2011",
        "pmid": "21642682",
        "source": "JAMA. 2011;305(15):1553-1559",
        "title": "A predictive model for progression of chronic kidney disease to kidney failure"
      },
      "formula": "kfre",
      "formula_expression": "LP = -0.2201*(age_years/10 - 7.036) + 0.2467*(male - 0.5642) - 0.5567*(egfr_ml_min/5 - 7.222) + 0.4510*(ln(acr_mg_g) - 5.137); 2-year risk = 1 - 0.9750^exp(LP); 5-year risk = 1 - 0.9240^exp(LP); Tangri 2011 4-variable only; male is 1 if true else 0; ACR mg/g natural log; caller supplies eGFR; not 8-variable; not Tangri 2016 country S0; no race",
      "age_years": 55,
      "linear_predictor": 1.3815,
      "acr_mg_g": 300.0,
      "egfr_ml_min": 30.0,
      "five_year_risk_percent": 27.0,
      "male": true,
      "s0_2_year": 0.975,
      "s0_5_year": 0.924,
      "two_year_risk_percent": 9.6
    },
    {
      "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.",
      "citation": {
        "authors": "Tangri N, Stevens LA, Griffith J, Tighiouart H, Djurdjev O, Naimark D, Levin A, Levey AS",
        "doi": "10.1001/jama.2011.451",
        "id": "tangri-2011",
        "pmid": "21642682",
        "source": "JAMA. 2011;305(15):1553-1559",
        "title": "A predictive model for progression of chronic kidney disease to kidney failure"
      },
      "formula": "kfre",
      "formula_expression": "LP = -0.2201*(age_years/10 - 7.036) + 0.2467*(male - 0.5642) - 0.5567*(egfr_ml_min/5 - 7.222) + 0.4510*(ln(acr_mg_g) - 5.137); 2-year risk = 1 - 0.9750^exp(LP); 5-year risk = 1 - 0.9240^exp(LP); Tangri 2011 4-variable only; male is 1 if true else 0; ACR mg/g natural log; caller supplies eGFR; not 8-variable; not Tangri 2016 country S0; no race",
      "age_years": 55,
      "linear_predictor": 1.3815,
      "acr_mg_g": 300.0,
      "egfr_ml_min": 30.0,
      "five_year_risk_percent": 27.0,
      "male": true,
      "s0_2_year": 0.975,
      "s0_5_year": 0.924,
      "two_year_risk_percent": 9.6
    }
  ]
}
```

## Response fields

- `formula` (string): kfre
- `formula_expression` (string): Tangri 2011 4-variable LP and 2-year/5-year S0
- `age_years` (integer): Age in years used (18-90)
- `male` (boolean): Caller-assigned male flag used
- `egfr_ml_min` (number): Caller-supplied eGFR used, mL/min/1.73 m2
- `acr_mg_g` (number): Urine ACR used, mg/g
- `linear_predictor` (number): Tangri 2011 4-variable centered LP, 4 decimals
- `two_year_risk_percent` (number): 2-year kidney-failure risk percent, 1 decimal (1 - 0.9750^exp(LP))
- `five_year_risk_percent` (number): 5-year kidney-failure risk percent, 1 decimal (1 - 0.9240^exp(LP))
- `s0_2_year` (number): Tangri 2011 4-variable 2-year baseline survival (0.9750)
- `s0_5_year` (number): Tangri 2011 4-variable 5-year baseline survival (0.9240)
- `citation` (object): Tangri et al. JAMA 2011 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "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.",
  "citation": {
    "authors": "Tangri N, Stevens LA, Griffith J, Tighiouart H, Djurdjev O, Naimark D, Levin A, Levey AS",
    "doi": "10.1001/jama.2011.451",
    "id": "tangri-2011",
    "pmid": "21642682",
    "source": "JAMA. 2011;305(15):1553-1559",
    "title": "A predictive model for progression of chronic kidney disease to kidney failure"
  },
  "formula": "kfre",
  "formula_expression": "LP = -0.2201*(age_years/10 - 7.036) + 0.2467*(male - 0.5642) - 0.5567*(egfr_ml_min/5 - 7.222) + 0.4510*(ln(acr_mg_g) - 5.137); 2-year risk = 1 - 0.9750^exp(LP); 5-year risk = 1 - 0.9240^exp(LP); Tangri 2011 4-variable only; male is 1 if true else 0; ACR mg/g natural log; caller supplies eGFR; not 8-variable; not Tangri 2016 country S0; no race",
  "age_years": 55,
  "linear_predictor": 1.3815,
  "acr_mg_g": 300.0,
  "egfr_ml_min": 30.0,
  "five_year_risk_percent": 27.0,
  "male": true,
  "s0_2_year": 0.975,
  "s0_5_year": 0.924,
  "two_year_risk_percent": 9.6
}
```

## Errors

- HTTP 400 `invalid_kfre`: Kidney failure risk inputs must be numeric age, eGFR, and urine ACR with a binary sex as used in Tangri 2011. Returned before settlement; you are not charged.
- HTTP 400 `invalid_items`: POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
- HTTP 400 `invalid_item_count`: items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
- HTTP 400 `invalid_item`: each items entry must be a JSON object Returned before settlement; you are not charged.

Shared HTTP 402 and 503: https://magentlab.com/docs/payments

## Related tools

- [CKD-EPI 2021 eGFR](https://magentlab.com/docs/egfr) — Compute race-free CKD-EPI 2021 creatinine eGFR in mL/min/1.73m2.
- [Cockcroft–Gault CrCl](https://magentlab.com/docs/crcl) — Compute Cockcroft–Gault creatinine clearance in mL/min using total body weight.

## Payment

Unpaid requests return HTTP 402 even if query parameters or POST items are missing or invalid, so CDP and agents can index the path. After a PAYMENT-SIGNATURE, invalid params return HTTP 400 JSON before settlement. magent does not charge. Fix the params, then request a new 402 quote for that complete URL. Catalog misses (empty matches, found=false) are valid paid 200s.

- GET the tool with Accept: application/json (do not send Accept: text/html unless you want the human paywall).
- HTTP 402 means you have not paid. Decode the base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote.
- Sign accepts[0] (exact, EIP-3009) with validBefore = now + maxTimeoutSeconds (600 seconds), or accepts[1] (batch-settlement deposit/voucher) on product GET. Ping and POST {items} stay exact. Magent retries transient facilitator 429/5xx before answering.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON of accepted and payload). Magent attaches canonical extensions.bazaar on CDP verify/settle; echoing 402 bazaar is optional.
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. exact settles before the tool. batch-settlement verifies (and deposit-settles) before the tool and commits the charge after HTTP 2xx. HTTP 503: retry the same PAYMENT-SIGNATURE. Mint a new exact nonce only after a new HTTP 402.

- offered `exact` on eip155:8453: Fixed-price USDC on Base. The buyer authorizes the advertised amount (EIP-3009). magent settles before the tool runs (paymentFlow upfront). extra.assetTransferMethod=eip3009 extra.paymentFlow=upfront.
- offered `batch-settlement` on eip155:8453: Payment-channel vouchers claimed later in batches. Exact stays accepts[0]. Same-path POST {items} is still exact. extra.assetTransferMethod=eip3009 extra.paymentFlow=authorization.

- not offered `upto`: Not offered. Usage-based: buyer authorizes a ceiling, seller settles the actual amount after work. Reserved for a future metered tool. Not for current calculators or code search.

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for GET unit plus $0.002 per extra item. That is not x402 batch-settlement (payment channels / vouchers).

Shared HTTP 402 and 503 table: https://magentlab.com/docs/payments

Stdio MCP (one process per host): https://magentlab.com/docs/mcp

## Guarantees

- HTTP 402 is unpaid, including a missing query. After PAYMENT-SIGNATURE, invalid parameters return HTTP 400 before settlement. You are not charged. HTTP 402 never includes the tool JSON.
- exact: settlement finishes before the tool (paymentFlow upfront). batch-settlement: verify/deposit before the tool; chargedCumulativeAmount commits after HTTP 2xx. Uncertain or failed settlement fails closed (HTTP 503). Retry the same PAYMENT-SIGNATURE.
- HTTP 402 is unpaid only. Do not sign a second authorization because of a 503.
- Execution is timeout-bounded and concurrency-capped.
- Calculator inputs are stored encrypted for allowlisted operators (Magent Console). They are not in public logs, SSH lookups, catalog, or rollups. Request logs store path without query.
