# FIB-4

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

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

## What it computes

Compute the FIB-4 fibrosis index from age, AST, ALT, and platelets.

## When to use

When an agent needs MASH/NASH prior-auth arithmetic and must not invent the index.

## When not to use

- Not a diagnosis. Sterling bands are published cut-points, not a biopsy.
- Does not apply NAFLD-specific alternative cut-points unless those values happen to match Sterling 2006.

## Formula

```
FIB-4 = (age_years * AST_U_L) / (platelets_10e9_L * sqrt(ALT_U_L))
```

## Citation

Development of a simple noninvasive index to predict significant fibrosis in patients with HIV/HCV coinfection
Sterling RK, Lissen E, Clumeck N, et al.
Hepatology. 2006;43(6):1317-1325
DOI: [10.1002/hep.21172](https://doi.org/10.1002/hep.21172)

## Worked example

### Published-style example

Given: `age=50, alt_u_l=40, ast_u_l=100, platelets_10e9_l=200`

1. FIB-4 = (50 × 100) / (200 × sqrt(40)) = 3.9528…
2. Round to 2 decimals → 3.95
3. Sterling band >3.25 → high


## Parameters

- `age` (integer, required): Age in years (18-120).
- `ast_u_l` (number, required): Aspartate aminotransferase in U/L (1-10000).
- `alt_u_l` (number, required): Alanine aminotransferase in U/L (1-10000).
- `platelets_10e9_l` (number, required): Platelet count in 10^9/L (1-2000).

## Bulk (POST)

POST the same path with a JSON items array. Price is n times the GET unit. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/fib4`
Max items: 25
Price: unit_amount * n (unit 5000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- 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": [
    {
      "age": "50",
      "alt_u_l": "40",
      "ast_u_l": "100",
      "platelets_10e9_l": "200"
    },
    {
      "age": "50",
      "alt_u_l": "40",
      "ast_u_l": "100",
      "platelets_10e9_l": "200"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/fib4",
  "items": [
    {
      "disclaimer": "Not a medical device. Deterministic published-formula or coded-ontology output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Sterling RK, Lissen E, Clumeck N, et al.",
        "doi": "10.1002/hep.21172",
        "id": "sterling-2006",
        "source": "Hepatology. 2006;43(6):1317-1325",
        "title": "Development of a simple noninvasive index to predict significant fibrosis in patients with HIV/HCV coinfection"
      },
      "formula": "fib4",
      "formula_expression": "FIB-4 = (age_years * AST_U_L) / (platelets_10e9_L * sqrt(ALT_U_L))",
      "age_years": 50,
      "alt_u_l": 40.0,
      "ast_u_l": 100.0,
      "fib4": 3.95,
      "platelets_10e9_l": 200.0,
      "sterling_band": "high"
    },
    {
      "disclaimer": "Not a medical device. Deterministic published-formula or coded-ontology output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Sterling RK, Lissen E, Clumeck N, et al.",
        "doi": "10.1002/hep.21172",
        "id": "sterling-2006",
        "source": "Hepatology. 2006;43(6):1317-1325",
        "title": "Development of a simple noninvasive index to predict significant fibrosis in patients with HIV/HCV coinfection"
      },
      "formula": "fib4",
      "formula_expression": "FIB-4 = (age_years * AST_U_L) / (platelets_10e9_L * sqrt(ALT_U_L))",
      "age_years": 50,
      "alt_u_l": 40.0,
      "ast_u_l": 100.0,
      "fib4": 3.95,
      "platelets_10e9_l": 200.0,
      "sterling_band": "high"
    }
  ]
}
```

## Response fields

- `formula` (string): fib4
- `formula_expression` (string): Exact expression used
- `age_years` (integer): Age used in the equation
- `ast_u_l` (number): AST in U/L
- `alt_u_l` (number): ALT in U/L
- `platelets_10e9_l` (number): Platelets in 10^9/L
- `fib4` (number): FIB-4 index, 2 decimal places
- `sterling_band` (string): Published Sterling 2006 cut-points: low (<1.45), indeterminate (1.45-3.25), high (>3.25). Not a diagnosis.
- `citation` (object): Hepatology 2006 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 coded-ontology output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
  "citation": {
    "authors": "Sterling RK, Lissen E, Clumeck N, et al.",
    "doi": "10.1002/hep.21172",
    "id": "sterling-2006",
    "source": "Hepatology. 2006;43(6):1317-1325",
    "title": "Development of a simple noninvasive index to predict significant fibrosis in patients with HIV/HCV coinfection"
  },
  "formula": "fib4",
  "formula_expression": "FIB-4 = (age_years * AST_U_L) / (platelets_10e9_L * sqrt(ALT_U_L))",
  "age_years": 50,
  "alt_u_l": 40.0,
  "ast_u_l": 100.0,
  "fib4": 3.95,
  "platelets_10e9_l": 200.0,
  "sterling_band": "high"
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_ast`: ast_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
- HTTP 400 `invalid_alt`: alt_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
- HTTP 400 `invalid_platelets`: platelets_10e9_l must be a number from 1 to 2000 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.
- HTTP 402 `payment_required`: Missing or invalid PAYMENT-SIGNATURE; decode the PAYMENT-REQUIRED header
- HTTP 409 `payment_in_progress`: The same authorization nonce is already being settled; retry shortly
- HTTP 429 `rate_limited`: Too many requests from this client
- HTTP 503 `settlement_uncertain`: Settlement is unconfirmed; retry with the same PAYMENT-SIGNATURE
- HTTP 503 `facilitator_unavailable`: Payment facilitator unavailable
- HTTP 503 `facilitator_misconfigured`: Payment facilitator is not configured
- HTTP 503 `facilitator_unauthorized`: Payment facilitator rejected credentials
- HTTP 503 `ledger_unavailable`: Payment ledger unavailable
- HTTP 503 `payment_unavailable`: Payment processing unavailable

## Related tools

- [MELD-Na](https://magentlab.com/docs/meld-na) — Compute OPTN/UNOS 2016 MELD and MELD-Na from creatinine, bilirubin, INR, sodium, and dialysis.

## Also searched as

- FIB4
- fibrosis-4
- Sterling FIB-4
- NASH FIB-4

## Payment

Required query parameters must be present and valid. 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.

## Guarantees

- Invalid query parameters return HTTP 400 before settlement. You are not charged.
- Settlement finishes before the tool executes. Uncertain settlement fails closed (HTTP 503).
- Execution is timeout-bounded and concurrency-capped.
- Calculator inputs are not persisted. Request logs store path without query.
