MAGENT

Liver · LIVE

FIB-4 calculator x402 API for agents

FIB-4

Agents must not invent FIB-4 from model memory. This endpoint computes the published Sterling 2006 FIB-4 fibrosis index from age, AST, ALT, and platelets; pay per request with x402 USDC on Base.

LIVE $0.005 USDC GET /api/calc/fib4

Markdown: /docs/fib4.md · Canonical: https://magentlab.com/docs/fib4

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

What it computes

Agents must not invent FIB-4 from model memory. This endpoint computes the published Sterling 2006 FIB-4 fibrosis index from age, AST, ALT, and platelets; pay per request with x402 USDC on Base.

When to use

When an agent needs the cited Sterling 2006 FIB-4 fibrosis index rather than a language-model guess, including for MASH/NASH prior-auth arithmetic. Pay per request with x402 USDC. Not a diagnosis or dosing recommendation.

When not to use

  • Not a medical device. 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

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

Worked example

Published-style example

Given: age=50alt_u_l=40ast_u_l=100platelets_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

Also searched as

  • FIB4
  • fibrosis-4
  • Sterling FIB-4
  • NASH FIB-4
  • FIB-4 calculator
  • fib4

Try

Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.

/api/calc/fib4?age=50&ast_u_l=100&alt_u_l=40&platelets_10e9_l=200

Full URL: https://api.magentlab.com/api/calc/fib4?age=50&ast_u_l=100&alt_u_l=40&platelets_10e9_l=200

Call

Expect HTTP 402 until you retry with PAYMENT-SIGNATURE. Incomplete query params return HTTP 400 before any quote or charge.

curl -i -H "Accept: application/json" "https://api.magentlab.com/api/calc/fib4?age=50&ast_u_l=100&alt_u_l=40&platelets_10e9_l=200"

Parameters

Name Type Required Description
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. The first item is the GET unit; each additional item is $0.002. Invalid items return HTTP 400 before settlement.

POST /api/calc/fib4 Max 25 unit_amount + extra_item_amount * (n - 1) extra $0.002 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 (fixture)

{
  "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"
    }
  ]
}

Open bulk paywall →

Opens a two-item fixture on the API host. Unpaid browsers get the same MetaMask paywall as GET; Pay retries POST with those items.

Example 200 (fixture)

{
  "count": 2,
  "path": "/api/calc/fib4",
  "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": "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))",
      "ast_u_l": 100.0,
      "platelets_10e9_l": 200.0,
      "age_years": 50,
      "alt_u_l": 40.0,
      "fib4": 3.95,
      "sterling_band": "high"
    },
    {
      "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": "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))",
      "ast_u_l": 100.0,
      "platelets_10e9_l": 200.0,
      "age_years": 50,
      "alt_u_l": 40.0,
      "fib4": 3.95,
      "sterling_band": "high"
    }
  ]
}

Response

Field Type Description
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

Machine form of the same example. Frozen fixture. Not a live lookup.

{
  "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": "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))",
  "ast_u_l": 100.0,
  "platelets_10e9_l": 200.0,
  "age_years": 50,
  "alt_u_l": 40.0,
  "fib4": 3.95,
  "sterling_band": "high"
}

Client errors (HTTP 400)

Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.

HTTP Code When
400 invalid_age age must be an integer from 18 to 120 Returned before settlement; you are not charged.
400 invalid_ast ast_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
400 invalid_alt alt_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
400 invalid_platelets platelets_10e9_l must be a number from 1 to 2000 Returned before settlement; you are not charged.
400 invalid_items POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
400 invalid_item_count items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
400 invalid_item each items entry must be a JSON object Returned before settlement; you are not charged.

Related tools

  • MELD-Na — Agents must not invent MELD-Na from model memory. This endpoint computes the published OPTN/UNOS 2016 MELD-Na score from creatinine, bilirubin, INR, sodium, and dialysis; pay per request with x402 USDC on Base.
  • Maddrey DF — Compute the 1978 Maddrey discriminant function from patient PT, control PT, and bilirubin.

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. Unpaid valid requests return HTTP 402 with a base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote: retry the same PAYMENT-SIGNATURE. Full handshake and shared payment errors: Payments. Stdio MCP: /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.