MAGENT

Liver · LIVE

SAFE score

Compute the Sripongpun 2023 steatosis-associated fibrosis estimator (SAFE) from age, caller-supplied BMI, diabetes, AST, ALT, globulin in g/dL, and platelets.

LIVE $0.005 USDC GET /api/calc/safe

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

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

What it computes

Compute the Sripongpun 2023 steatosis-associated fibrosis estimator (SAFE) from age, caller-supplied BMI, diabetes, AST, ALT, globulin in g/dL, and platelets.

When to use

When an agent needs published Sripongpun 2023 SAFE arithmetic and must not invent FIB-4, NAFLD fibrosis, or BARD cutoffs or a biopsy result.

When not to use

  • Not a medical device. Not a diagnosis and not a biopsy or fibrosis stage. SAFE bands are published cut-points, not histology.
  • BMI is caller-supplied. magent does not compute BMI from height and weight in this tool. BMI above 40 is set to 40 in the formula only (Sripongpun 2023).
  • Sripongpun 2023 SAFE only. Not FIB-4, not the NAFLD fibrosis score, and not the BARD score.
  • Globulin must be in g/dL (total protein minus albumin). magent does not convert g/L or split protein and albumin.

Formula

SAFE = 2.97*age + 5.99*min(BMI, 40) + 154.85*ln(AST) - 58.23*ln(ALT) + 195.48*ln(globulin_g_dl) - 141.61*ln(platelets_10e9_l) + 62.85*(diabetes 0/1) - 75

Citation

Title
The steatosis-associated fibrosis estimator (SAFE) score: A tool to detect low-risk NAFLD in primary care
Authors
Sripongpun P, Kim WR, Mannalithara A, et al.
Source
Hepatology. 2023;77(1):256-267
DOI
10.1002/hep.32545

Worked example

Age 50, BMI 30, no diabetes, AST/ALT 40, globulin 3, platelets 200

Given: age=50alt_u_l=40ast_u_l=40bmi_kg_m2=30diabetes=falseglobulin_g_dl=3platelets_10e9_l=200

  1. BMI used = min(30, 40) = 30; diabetes = 0
  2. SAFE = 2.97*50 + 5.99*30 + 154.85*ln(40) - 58.23*ln(40) + 195.48*ln(3) - 141.61*ln(200) + 62.85*0 - 75 = 74.08
  3. 0 <= 74.08 <= 100 → safe_band 0_to_100

Also searched as

  • SAFE score
  • steatosis-associated fibrosis estimator
  • NAFLD SAFE
  • Sripongpun SAFE
  • SAFE NAFLD fibrosis
  • globulin platelet NAFLD score

Try

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

/api/calc/safe?age=50&bmi_kg_m2=30&diabetes=false&ast_u_l=40&alt_u_l=40&globulin_g_dl=3&platelets_10e9_l=200

Full URL: https://api.magentlab.com/api/calc/safe?age=50&bmi_kg_m2=30&diabetes=false&ast_u_l=40&alt_u_l=40&globulin_g_dl=3&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/safe?age=50&bmi_kg_m2=30&diabetes=false&ast_u_l=40&alt_u_l=40&globulin_g_dl=3&platelets_10e9_l=200"

Parameters

Name Type Required Description
age integer required Age in years (18-120).
bmi_kg_m2 number required Body-mass index in kg/m^2 (10-80). Caller-supplied; magent does not compute BMI from height and weight. Values above 40 are set to 40 in the formula only (Sripongpun 2023); the caller BMI is still echoed.
diabetes boolean required Diabetes as assigned by the caller (Sripongpun 2023; 0 or 1 in the equation). true or false. magent does not diagnose diabetes.
ast_u_l number required Aspartate aminotransferase in U/L (1-10000).
alt_u_l number required Alanine aminotransferase in U/L (1-10000).
globulin_g_dl number required Globulin in g/dL (0.5-8.0). Total protein minus albumin. magent does not convert g/L or split protein and albumin.
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/safe 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": "40",
      "bmi_kg_m2": "30",
      "diabetes": "false",
      "globulin_g_dl": "3",
      "platelets_10e9_l": "200"
    },
    {
      "age": "50",
      "alt_u_l": "40",
      "ast_u_l": "40",
      "bmi_kg_m2": "30",
      "diabetes": "false",
      "globulin_g_dl": "3",
      "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/safe",
  "items": [
    {
      "safe": 74.08,
      "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": "Sripongpun P, Kim WR, Mannalithara A, et al.",
        "doi": "10.1002/hep.32545",
        "id": "sripongpun-2023",
        "pmid": "35477908",
        "source": "Hepatology. 2023;77(1):256-267",
        "title": "The steatosis-associated fibrosis estimator (SAFE) score: A tool to detect low-risk NAFLD in primary care"
      },
      "formula": "safe",
      "formula_expression": "SAFE = 2.97*age + 5.99*min(BMI, 40) + 154.85*ln(AST) - 58.23*ln(ALT) + 195.48*ln(globulin_g_dl) - 141.61*ln(platelets_10e9_l) + 62.85*(diabetes 0/1) - 75",
      "age_years": 50,
      "ast_u_l": 40.0,
      "platelets_10e9_l": 200.0,
      "alt_u_l": 40.0,
      "diabetes": false,
      "bmi_kg_m2": 30.0,
      "bmi_used": 30.0,
      "globulin_g_dl": 3.0,
      "safe_band": "0_to_100"
    },
    {
      "safe": 74.08,
      "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": "Sripongpun P, Kim WR, Mannalithara A, et al.",
        "doi": "10.1002/hep.32545",
        "id": "sripongpun-2023",
        "pmid": "35477908",
        "source": "Hepatology. 2023;77(1):256-267",
        "title": "The steatosis-associated fibrosis estimator (SAFE) score: A tool to detect low-risk NAFLD in primary care"
      },
      "formula": "safe",
      "formula_expression": "SAFE = 2.97*age + 5.99*min(BMI, 40) + 154.85*ln(AST) - 58.23*ln(ALT) + 195.48*ln(globulin_g_dl) - 141.61*ln(platelets_10e9_l) + 62.85*(diabetes 0/1) - 75",
      "age_years": 50,
      "ast_u_l": 40.0,
      "platelets_10e9_l": 200.0,
      "alt_u_l": 40.0,
      "diabetes": false,
      "bmi_kg_m2": 30.0,
      "bmi_used": 30.0,
      "globulin_g_dl": 3.0,
      "safe_band": "0_to_100"
    }
  ]
}

Response

Field Type Description
formula string safe
formula_expression string Exact Sripongpun 2023 expression (natural log; BMI capped at 40)
age_years integer Age in years used
bmi_kg_m2 number Caller-supplied BMI in kg/m^2
bmi_used number BMI used in the equation (caller BMI, or 40 when caller BMI > 40)
diabetes boolean Diabetes flag used
ast_u_l number AST in U/L
alt_u_l number ALT in U/L
globulin_g_dl number Globulin in g/dL
platelets_10e9_l number Platelets in 10^9/L
safe number SAFE score, 2 decimals
safe_band string Published Sripongpun 2023 cut-points on the rounded score: lt_0 (rule-out / low risk; NPV at 0), 0_to_100 (indeterminate), gt_100 (rule-in / high risk). Not a diagnosis.
citation object Sripongpun Hepatology 2023 citation
disclaimer string Not-a-device notice

Example JSON

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

{
  "safe": 74.08,
  "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": "Sripongpun P, Kim WR, Mannalithara A, et al.",
    "doi": "10.1002/hep.32545",
    "id": "sripongpun-2023",
    "pmid": "35477908",
    "source": "Hepatology. 2023;77(1):256-267",
    "title": "The steatosis-associated fibrosis estimator (SAFE) score: A tool to detect low-risk NAFLD in primary care"
  },
  "formula": "safe",
  "formula_expression": "SAFE = 2.97*age + 5.99*min(BMI, 40) + 154.85*ln(AST) - 58.23*ln(ALT) + 195.48*ln(globulin_g_dl) - 141.61*ln(platelets_10e9_l) + 62.85*(diabetes 0/1) - 75",
  "age_years": 50,
  "ast_u_l": 40.0,
  "platelets_10e9_l": 200.0,
  "alt_u_l": 40.0,
  "diabetes": false,
  "bmi_kg_m2": 30.0,
  "bmi_used": 30.0,
  "globulin_g_dl": 3.0,
  "safe_band": "0_to_100"
}

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_bmi_kg_m2 bmi_kg_m2 must be a number from 10 to 80. Returned before settlement; you are not charged.
400 invalid_flag boolean clinical flags must be true or false 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_globulin globulin_g_dl must be a number from 0.5 to 8.0 (g/dL; total protein minus albumin). 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

  • FIB-4 — Compute the FIB-4 fibrosis index from age, AST, ALT, and platelets.
  • NAFLD fibrosis score — Compute the Angulo 2007 NAFLD fibrosis score from age, BMI, IFG/diabetes, AST, ALT, platelets, and albumin.
  • Fatty liver index — Compute the Bedogni 2006 fatty liver index from caller-supplied BMI, waist circumference, triglycerides, and GGT as a predictor of hepatic steatosis in the general population.
  • BARD — Sum the Harrison 2008 BARD score (BMI ≥28, AST/ALT ≥0.8, diabetes) and return low (0–1) or high (2–4).

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.