# Bicarbonate Deficit Calculator (Adrogué–Madias)

> Bicarbonate Deficit Calculator (Adrogué–Madias) is a paid API for AI agents from api.magentlab.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-15).

Calculates the bicarbonate deficit from patient weight and measured plasma HCO3 using the Adrogué–Madias 50% body-weight space formula.

## Facts

- Endpoint: GET https://api.magentlab.com/api/calc/bicarbonate_deficit
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/bicarbonate-deficit-calculator-adrogu-madias-ecc56f45
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_1EUpCreG0BhbXOCpHTqqp

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability bicarbonate-deficit-calculator-adrogu-madias-ecc56f45
```

Example prompt: What's the bicarbonate deficit for a 70 kg patient with a measured plasma bicarbonate of 12 mmol/L, targeting 24 mmol/L? Use the Adrogué–Madias formula.

## When to prefer this

Choose this endpoint when you need a fast, deterministic, citation-backed bicarbonate deficit calculation using the Adrogué–Madias 50% body-weight distribution model. It is ideal for clinical decision-support agents, medical education tools, or audit workflows where reproducibility and published formula provenance matter. It is not a dosing protocol and should not replace clinical judgment.

## Known failure modes

- Missing required bicarbonate_mmol_l parameter returns a 400 error
- bicarbonate_mmol_l outside the valid range of 2–45 mmol/L returns a validation error
- desired_hco3_mmol_l must exceed measured HCO3 or the calculation is invalid
- desired_hco3_mmol_l outside 8–30 mmol/L range rejected
- Neither weight_kg nor weight_lb provided may result in a missing-weight error
- Payment not attached or insufficient USDC (x402) returns 402 Payment Required

## How this service works

Bicarbonate deficit from weight and measured HCO3 using Adrogué–Madias 50 percent body-weight space. Deterministic published arithmetic with citation; not a dosing protocol.

## Output

Returns the calculated bicarbonate deficit in mmol based on the Adrogué–Madias formula (deficit = 0.5 × weight_kg × (desired_HCO3 − measured_HCO3)), along with the formula citation and input echo. This is a deterministic arithmetic result, not a clinical dosing protocol.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "headers": {
     "type": "object",
     "additionalProperties": {
      "type": "string"
     }
    },
    "queryParams": {
     "type": "object",
     "required": [
      "bicarbonate_mmol_l"
     ],
     "properties": {
      "weight_kg": {
       "type": "number",
       "description": "Weight in kilograms. Provide weight_kg or weight_lb."
      },
      "weight_lb": {
       "type": "number",
       "description": "Weight in pounds. Converted as kg = lb * 0.45359237."
      },
      "bicarbonate_mmol_l": {
       "type": "number",
       "description": "Measured plasma bicarbonate in mmol/L (same as mEq/L). Range 2-45."
      },
      "desired_hco3_mmol_l": {
       "type": "number",
       "description": "Target plasma bicarbonate in mmol/L (8-30), must exceed measured HCO3. Omitted uses 24."
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "path": "/api/calc/bicarbonate_deficit",
  "count": 2,
  "items": [
   {
    "formula": "adrogue_madias",
    "citation": {
     "id": "adrogue-madias-1998",
     "doi": "10.1056/NEJM199801013380106",
     "title": "Management of life-threatening acid-base disorders. First of two parts",
     "source": "N Engl J Med. 1998;338(1):26-34",
     "authors": "Adrogué HJ, Madias NE"
    },
    "weight_kg": 70,
    "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.",
    "deficit_meq": 140,
    "bicarbonate_mmol_l": 4,
    "formula_expression": "bicarbonate_space_L = 0.5 * weight_kg; deficit_mEq = bicarbonate_space_L * (desired_hco3 - measured_hco3)",
    "bicarbonate_space_l": 35,
    "desired_hco3_mmol_l": 8
   },
   {
    "formula": "adrogue_madias",
    "citation": {
     "id": "adrogue-madias-1998",
     "doi": "10.1056/NEJM199801013380106",
     "title": "Management of life-threatening acid-base disorders. First of two parts",
     "source": "N Engl J Med. 1998;338(1):26-34",
     "authors": "Adrogué HJ, Madias NE"
    },
    "weight_kg": 70,
    "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.",
    "deficit_meq": 140,
    "bicarbonate_mmol_l": 4,
    "formula_expression": "bicarbonate_space_L = 0.5 * weight_kg; deficit_mEq = bicarbonate_space_L * (desired_hco3 - measured_hco3)",
    "bicarbonate_space_l": 35,
    "desired_hco3_mmol_l": 8
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/bicarbonate-deficit-calculator-adrogu-madias-ecc56f45/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.magentlab.com](https://www.zero.xyz/host/api.magentlab.com/llms.txt)
