Electrolytes / glucose · LIVE
Acid-base assessment (Berend)
Apply the Berend 2014 physiological stepwise assessment: pH acidemia or alkalemia, Table 1 primary metabolic versus respiratory process, anion gap, optional albumin-corrected gap, and printed delta-delta.
Markdown: /docs/abg.md · Canonical: https://magentlab.com/docs/abg
Not a medical device. Not a diagnosis, dose, or listing recommendation.
What it computes
Apply the Berend 2014 physiological stepwise assessment: pH acidemia or alkalemia, Table 1 primary metabolic versus respiratory process, anion gap, optional albumin-corrected gap, and printed delta-delta.
When to use
When an agent has arterial pH, PaCO2, bicarbonate, sodium, and chloride and needs Berend 2014 stepwise labels and numeric intermediates.
When not to use
- Not a medical device and not a diagnosis. magent does not assay arterial blood gas, assign a cause, or replace clinical context.
- Not a ventilator setting, oxygen prescription, or bicarbonate dose.
- Expected PaCO2 in metabolic acidosis is the Table 1 Winters secondary response (1.5×HCO3+8±2), not a treatment target. Standalone Winters is the related winters tool.
- Anion gap uses Na−Cl−HCO3. High versus normal uses Berend's example upper reference of 12 mmol/L; the paper states the laboratory range is analyzer-specific.
- Albumin correction uses Figure 1 (2.5 mmol/L per 1 g/dL decrease). Berend does not print a reference albumin; this tool uses 4.0 g/dL as the decrement baseline and does not reverse-correct hyperalbuminemia.
- Delta-delta is returned only when the anion gap is high. Both ketoacidosis (1:1) and lactic (0.6) printed equations are returned; magent does not pick one from lactate.
- Does not compute A-a difference, osmolal gap, or urinary anion gap.
Formula
Berend 2014: acidemia if pH<7.38; alkalemia if pH>7.42; metabolic acidosis if pH<7.38 and HCO3<22; metabolic alkalosis if pH>7.42 and HCO3>26; respiratory acidosis if pH<7.38 and PaCO2>42; respiratory alkalosis if pH>7.42 and PaCO2<38; anion_gap=Na-Cl-HCO3 (high if >12); albumin-corrected AG=AG+2.5*(4.0-albumin) when albumin<4.0 g/dL; metabolic acidosis expected PaCO2=1.5*HCO3+8±2; metabolic alkalosis expected PaCO2=0.7*(HCO3-24)+40±2; acute respiratory acidosis HCO3 +1 per 10 mm Hg PaCO2 above 40; chronic +4 to +5; acute respiratory alkalosis HCO3 -2 per 10 mm Hg PaCO2 below 40; chronic -4 to -5; ketoacidosis delta-delta=ΔAG-ΔHCO3; lactic delta-delta=0.6*ΔAG-ΔHCO3 (simple if -5 to 5)
Citation
- Authors
- Berend K, de Vries APJ, Gans ROB
- Source
- N Engl J Med. 2014;371:1434-1445
Worked example
Berend 2014 Patient 1 saline acidosis
Given:
bicarbonate_mmol_l=18chloride_mmol_l=115paco2_mm_hg=39ph=7.28sodium_mmol_l=135
- pH 7.28 < 7.38 → acidemia
- HCO3 18 < 22 with acidemia → metabolic acidosis; PaCO2 39 is not >42 → not a Table 1 respiratory primary
- anion_gap = 135 − 115 − 18 = 2.0 mmol/L (not >12 → normal anion-gap)
- expected PaCO2 = 1.5 × 18 + 8 = 35.0 mm Hg (band 33.0–37.0)
- measured PaCO2 39.0 > 37.0 → additional respiratory acidosis
Also searched as
- Berend acid-base
- acidemia alkalemia
- stepwise acid-base
- physiological acid-base
- delta delta anion gap
- albumin-corrected anion gap
- arterial blood gas assessment
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
/api/calc/abg?ph=7.28&paco2_mm_hg=39&bicarbonate_mmol_l=18&sodium_mmol_l=135&chloride_mmol_l=115
Full URL: https://api.magentlab.com/api/calc/abg?ph=7.28&paco2_mm_hg=39&bicarbonate_mmol_l=18&sodium_mmol_l=135&chloride_mmol_l=115
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/abg?ph=7.28&paco2_mm_hg=39&bicarbonate_mmol_l=18&sodium_mmol_l=135&chloride_mmol_l=115"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
ph |
number | required | Arterial pH (6.80-7.80). Acidemia if pH<7.38; alkalemia if pH>7.42 (Berend 2014 Table 1). |
paco2_mm_hg |
number | required | Arterial PaCO2 in mm Hg (8-120). Respiratory acidosis if pH<7.38 and PaCO2>42; respiratory alkalosis if pH>7.42 and PaCO2<38. |
bicarbonate_mmol_l |
number | required | Plasma bicarbonate in mmol/L (2-55). Metabolic acidosis if pH<7.38 and HCO3<22; metabolic alkalosis if pH>7.42 and HCO3>26. |
sodium_mmol_l |
number | required | Serum sodium in mmol/L (110-160). Used for anion gap Na-Cl-HCO3. |
chloride_mmol_l |
number | required | Serum chloride in mmol/L (70-130). Used for anion gap Na-Cl-HCO3. |
albumin_g_dl |
number | optional | Serum albumin in g/dL (1-6). When supplied and below 4.0 g/dL, anion gap is increased by 2.5 mmol/L per 1 g/dL decrease (Figure 1). Omitted skips the correction. |
lactate_mmol_l |
number | optional | Serum lactate in mmol/L (0-30) when supplied. Echoed only; magent does not pick keto vs lactic delta-delta from lactate. Both printed equations are returned when the anion gap is high. |
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.
- 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": [
{
"bicarbonate_mmol_l": "18",
"chloride_mmol_l": "115",
"paco2_mm_hg": "39",
"ph": "7.28",
"sodium_mmol_l": "135"
},
{
"bicarbonate_mmol_l": "18",
"chloride_mmol_l": "115",
"paco2_mm_hg": "39",
"ph": "7.28",
"sodium_mmol_l": "135"
}
]
}
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/abg",
"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": "Berend K, de Vries APJ, Gans ROB",
"doi": "10.1056/NEJMra1003327",
"id": "berend-2014-acid-base",
"pmid": "25295502",
"source": "N Engl J Med. 2014;371:1434-1445",
"title": "Physiological Approach to Assessment of Acid-Base Disturbances"
},
"formula": "abg",
"formula_expression": "Berend 2014: acidemia if pH<7.38; alkalemia if pH>7.42; metabolic acidosis if pH<7.38 and HCO3<22; metabolic alkalosis if pH>7.42 and HCO3>26; respiratory acidosis if pH<7.38 and PaCO2>42; respiratory alkalosis if pH>7.42 and PaCO2<38; anion_gap=Na-Cl-HCO3 (high if >12); albumin-corrected AG=AG+2.5*(4.0-albumin) when albumin<4.0 g/dL; metabolic acidosis expected PaCO2=1.5*HCO3+8±2; metabolic alkalosis expected PaCO2=0.7*(HCO3-24)+40±2; acute respiratory acidosis HCO3 +1 per 10 mm Hg PaCO2 above 40; chronic +4 to +5; acute respiratory alkalosis HCO3 -2 per 10 mm Hg PaCO2 below 40; chronic -4 to -5; ketoacidosis delta-delta=ΔAG-ΔHCO3; lactic delta-delta=0.6*ΔAG-ΔHCO3 (simple if -5 to 5)",
"paco2_mm_hg": 39.0,
"secondary_response": "additional respiratory acidosis",
"anion_gap_class": "normal",
"anion_gap_mmol_l": 2.0,
"bicarbonate_mmol_l": 18.0,
"chloride_mmol_l": 115.0,
"criteria": [
{
"value": 7.28,
"factor": "acidemia",
"met": true
},
{
"value": 7.28,
"factor": "alkalemia",
"met": false
},
{
"value": 18.0,
"factor": "metabolic_acidosis",
"met": true
},
{
"value": 18.0,
"factor": "metabolic_alkalosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_acidosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_alkalosis",
"met": false
},
{
"value": 2.0,
"factor": "high_anion_gap",
"met": false
},
{
"value": 2.0,
"factor": "normal_anion_gap",
"met": true
}
],
"disorders": [
"acidemia",
"metabolic acidosis",
"normal anion-gap acidosis",
"additional respiratory acidosis"
],
"ph": 7.28,
"ph_status": "acidemia",
"primary_process": "metabolic acidosis",
"sodium_mmol_l": 135.0,
"expected_paco2_high_mm_hg": 37.0,
"expected_paco2_low_mm_hg": 33.0,
"expected_paco2_mm_hg": 35.0
},
{
"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": "Berend K, de Vries APJ, Gans ROB",
"doi": "10.1056/NEJMra1003327",
"id": "berend-2014-acid-base",
"pmid": "25295502",
"source": "N Engl J Med. 2014;371:1434-1445",
"title": "Physiological Approach to Assessment of Acid-Base Disturbances"
},
"formula": "abg",
"formula_expression": "Berend 2014: acidemia if pH<7.38; alkalemia if pH>7.42; metabolic acidosis if pH<7.38 and HCO3<22; metabolic alkalosis if pH>7.42 and HCO3>26; respiratory acidosis if pH<7.38 and PaCO2>42; respiratory alkalosis if pH>7.42 and PaCO2<38; anion_gap=Na-Cl-HCO3 (high if >12); albumin-corrected AG=AG+2.5*(4.0-albumin) when albumin<4.0 g/dL; metabolic acidosis expected PaCO2=1.5*HCO3+8±2; metabolic alkalosis expected PaCO2=0.7*(HCO3-24)+40±2; acute respiratory acidosis HCO3 +1 per 10 mm Hg PaCO2 above 40; chronic +4 to +5; acute respiratory alkalosis HCO3 -2 per 10 mm Hg PaCO2 below 40; chronic -4 to -5; ketoacidosis delta-delta=ΔAG-ΔHCO3; lactic delta-delta=0.6*ΔAG-ΔHCO3 (simple if -5 to 5)",
"paco2_mm_hg": 39.0,
"secondary_response": "additional respiratory acidosis",
"anion_gap_class": "normal",
"anion_gap_mmol_l": 2.0,
"bicarbonate_mmol_l": 18.0,
"chloride_mmol_l": 115.0,
"criteria": [
{
"value": 7.28,
"factor": "acidemia",
"met": true
},
{
"value": 7.28,
"factor": "alkalemia",
"met": false
},
{
"value": 18.0,
"factor": "metabolic_acidosis",
"met": true
},
{
"value": 18.0,
"factor": "metabolic_alkalosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_acidosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_alkalosis",
"met": false
},
{
"value": 2.0,
"factor": "high_anion_gap",
"met": false
},
{
"value": 2.0,
"factor": "normal_anion_gap",
"met": true
}
],
"disorders": [
"acidemia",
"metabolic acidosis",
"normal anion-gap acidosis",
"additional respiratory acidosis"
],
"ph": 7.28,
"ph_status": "acidemia",
"primary_process": "metabolic acidosis",
"sodium_mmol_l": 135.0,
"expected_paco2_high_mm_hg": 37.0,
"expected_paco2_low_mm_hg": 33.0,
"expected_paco2_mm_hg": 35.0
}
]
}
Response
| Field | Type | Description |
|---|---|---|
formula |
string | abg |
formula_expression |
string | Berend 2014 printed steps |
ph |
number | Arterial pH used, 2 decimals |
paco2_mm_hg |
number | Arterial PaCO2 used, 1 decimal |
bicarbonate_mmol_l |
number | Plasma bicarbonate used, 1 decimal |
sodium_mmol_l |
number | Serum sodium used, 1 decimal |
chloride_mmol_l |
number | Serum chloride used, 1 decimal |
anion_gap_mmol_l |
number | Na - Cl - HCO3 in mmol/L, 1 decimal |
anion_gap_class |
string | high if anion gap >12 mmol/L (Berend example upper reference); else normal |
ph_status |
string | acidemia, alkalemia, or normal |
primary_process |
string | Table 1 primary metabolic and/or respiratory process label |
disorders |
array | Berend 2014 disorder labels as strings |
expected_paco2_mm_hg |
number | Table 1 expected PaCO2 when a metabolic primary is present. Omitted otherwise. |
expected_paco2_low_mm_hg |
number | Expected PaCO2 minus 2 mm Hg. Omitted when expected PaCO2 is omitted. |
expected_paco2_high_mm_hg |
number | Expected PaCO2 plus 2 mm Hg. Omitted when expected PaCO2 is omitted. |
secondary_response |
string | appropriate, additional respiratory acidosis, or additional respiratory alkalosis versus the metabolic expected PaCO2 ±2 band. Omitted when no metabolic primary. |
hco3_change_per_10_mm_hg |
number | Change in HCO3 per 10 mm Hg PaCO2 from 40 when a respiratory primary is present. Omitted otherwise. |
respiratory_secondary |
string | acute, chronic, additional metabolic acidosis, or additional metabolic alkalosis when the printed per-10 mm Hg band is met. Omitted when no respiratory primary or the ratio is between printed bands. |
albumin_g_dl |
number | Serum albumin when supplied. Omitted when albumin_g_dl is not given. |
albumin_corrected_anion_gap_mmol_l |
number | Anion gap plus 2.5 mmol/L per 1 g/dL albumin decrease from 4.0 g/dL. Omitted when albumin is omitted. |
lactate_mmol_l |
number | Serum lactate when supplied. Omitted when lactate_mmol_l is not given. |
delta_ag_mmol_l |
number | Anion gap minus 12 (albumin-corrected when albumin is supplied). Omitted when anion gap is not high. |
delta_hco3_mmol_l |
number | 24 minus HCO3. Omitted when anion gap is not high. |
delta_delta_ketoacidosis_mmol_l |
number | ΔAG − ΔHCO3. Omitted when anion gap is not high. |
delta_delta_lactic_mmol_l |
number | 0.6×ΔAG − ΔHCO3. Omitted when anion gap is not high. |
mixed_metabolic_ketoacidosis |
string | Printed Δ-Δ ketoacidosis mixed-metabolic label. Omitted when AG is not high. |
mixed_metabolic_lactic |
string | Printed Δ-Δ lactic mixed-metabolic label. Omitted when AG is not high. |
criteria |
array | Tree rows for acidemia, alkalemia, primary processes, and anion-gap class |
citation |
object | Berend 2014 NEJM 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": "Berend K, de Vries APJ, Gans ROB",
"doi": "10.1056/NEJMra1003327",
"id": "berend-2014-acid-base",
"pmid": "25295502",
"source": "N Engl J Med. 2014;371:1434-1445",
"title": "Physiological Approach to Assessment of Acid-Base Disturbances"
},
"formula": "abg",
"formula_expression": "Berend 2014: acidemia if pH<7.38; alkalemia if pH>7.42; metabolic acidosis if pH<7.38 and HCO3<22; metabolic alkalosis if pH>7.42 and HCO3>26; respiratory acidosis if pH<7.38 and PaCO2>42; respiratory alkalosis if pH>7.42 and PaCO2<38; anion_gap=Na-Cl-HCO3 (high if >12); albumin-corrected AG=AG+2.5*(4.0-albumin) when albumin<4.0 g/dL; metabolic acidosis expected PaCO2=1.5*HCO3+8±2; metabolic alkalosis expected PaCO2=0.7*(HCO3-24)+40±2; acute respiratory acidosis HCO3 +1 per 10 mm Hg PaCO2 above 40; chronic +4 to +5; acute respiratory alkalosis HCO3 -2 per 10 mm Hg PaCO2 below 40; chronic -4 to -5; ketoacidosis delta-delta=ΔAG-ΔHCO3; lactic delta-delta=0.6*ΔAG-ΔHCO3 (simple if -5 to 5)",
"paco2_mm_hg": 39.0,
"secondary_response": "additional respiratory acidosis",
"anion_gap_class": "normal",
"anion_gap_mmol_l": 2.0,
"bicarbonate_mmol_l": 18.0,
"chloride_mmol_l": 115.0,
"criteria": [
{
"value": 7.28,
"factor": "acidemia",
"met": true
},
{
"value": 7.28,
"factor": "alkalemia",
"met": false
},
{
"value": 18.0,
"factor": "metabolic_acidosis",
"met": true
},
{
"value": 18.0,
"factor": "metabolic_alkalosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_acidosis",
"met": false
},
{
"value": 39.0,
"factor": "respiratory_alkalosis",
"met": false
},
{
"value": 2.0,
"factor": "high_anion_gap",
"met": false
},
{
"value": 2.0,
"factor": "normal_anion_gap",
"met": true
}
],
"disorders": [
"acidemia",
"metabolic acidosis",
"normal anion-gap acidosis",
"additional respiratory acidosis"
],
"ph": 7.28,
"ph_status": "acidemia",
"primary_process": "metabolic acidosis",
"sodium_mmol_l": 135.0,
"expected_paco2_high_mm_hg": 37.0,
"expected_paco2_low_mm_hg": 33.0,
"expected_paco2_mm_hg": 35.0
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_abg |
ABG acid-base inputs must match Berend 2014 pH, PaCO2, bicarbonate, sodium, chloride, albumin, and lactate as published. 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
- Winters' formula — Compute expected arterial PCO2 in metabolic acidosis from plasma bicarbonate using the Albert–Winters 1967 formula.
- Anion gap — Compute the serum anion gap from sodium, chloride, and bicarbonate, with or without potassium, using the Emmett–Narins 1977 formulas. formula is required.
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.