# Urine Anion Gap Calculator (Batlle 1988)

> Urine Anion Gap Calculator (Batlle 1988) 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 urine anion gap (Na + K − Cl) from urine electrolytes and returns an interpretive band distinguishing GI bicarbonate loss from renal tubular acidosis (RTA).

## Facts

- Endpoint: GET https://api.magentlab.com/api/calc/urine_anion_gap
- 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/urine-anion-gap-calculator-batlle-1988-d78ad133
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_e4V7ipnGQx2zXKMpUl6Q6

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 urine-anion-gap-calculator-batlle-1988-d78ad133
```

Example prompt: Calculate the urine anion gap for a patient with urine sodium 40 mmol/L, urine potassium 20 mmol/L, and urine chloride 80 mmol/L, and tell me whether the result suggests GI bicarbonate loss or renal tubular acidosis.

## When to prefer this

Choose this endpoint when you need a fast, citable, deterministic urine anion gap calculation with a built-in Batlle 1988 interpretive band for differentiating GI bicarbonate loss from renal tubular acidosis in the workup of non-anion gap metabolic acidosis. Prefer it over manual calculation when you need a machine-readable result with clinical interpretation text, or when logging acid-base assessments in an automated clinical workflow.

## Known failure modes

- Missing required query parameter (urine_sodium_mmol_l, urine_potassium_mmol_l, or urine_chloride_mmol_l) returns a validation error
- Values outside specified ranges (Na/Cl >300 or K >200 mmol/L) may return a range error or unexpected result
- Non-numeric input for electrolyte values returns a parsing error
- Payment failure (x402) blocks the request before computation occurs

## How this service works

Urine anion gap from urine sodium, potassium, and chloride (Na + K − Cl). Batlle 1988 interpretive band: negative suggests increased NH4+ (GI bicarbonate loss); positive suggests impaired NH4+ (RTA). Deterministic published arithmetic with citation; not a diagnosis.

## Output

Returns the numeric urine anion gap value (Na + K − Cl in mmol/L) along with a Batlle 1988 interpretive classification: a negative UAG suggests increased ammonium excretion consistent with GI bicarbonate loss (e.g. diarrhea), while a positive UAG suggests impaired NH4+ excretion consistent with renal tubular acidosis (RTA). Result is a deterministic arithmetic calculation with citation, not a clinical diagnosis.

## 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": [
      "urine_sodium_mmol_l",
      "urine_potassium_mmol_l",
      "urine_chloride_mmol_l"
     ],
     "properties": {
      "urine_sodium_mmol_l": {
       "type": "number",
       "description": "Urine sodium in mmol/L (same as mEq/L). Range 1-300."
      },
      "urine_chloride_mmol_l": {
       "type": "number",
       "description": "Urine chloride in mmol/L (same as mEq/L). Range 1-300."
      },
      "urine_potassium_mmol_l": {
       "type": "number",
       "description": "Urine potassium in mmol/L (same as mEq/L). Range 1-200."
      }
     }
    }
   },
   "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/urine_anion_gap",
  "count": 2,
  "items": [
   {
    "formula": "urine_anion_gap",
    "citation": {
     "id": "batlle-1988",
     "doi": "10.1056/NEJM198803033180902",
     "title": "The use of the urinary anion gap in the diagnosis of hyperchloremic metabolic acidosis",
     "source": "N Engl J Med. 1988;318(10):594-599",
     "authors": "Batlle DC, Hizon M, Cohen E, Gutterman C, Gupta R"
    },
    "uag_band": "negative",
    "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.",
    "formula_expression": "urine_anion_gap_mmol_l = urine_sodium_mmol_l + urine_potassium_mmol_l - urine_chloride_mmol_l",
    "urine_sodium_mmol_l": 20,
    "urine_chloride_mmol_l": 90,
    "urine_anion_gap_mmol_l": -40,
    "urine_potassium_mmol_l": 30
   },
   {
    "formula": "urine_anion_gap",
    "citation": {
     "id": "batlle-1988",
     "doi": "10.1056/NEJM198803033180902",
     "title": "The use of the urinary anion gap in the diagnosis of hyperchloremic metabolic acidosis",
     "source": "N Engl J Med. 1988;318(10):594-599",
     "authors": "Batlle DC, Hizon M, Cohen E, Gutterman C, Gupta R"
    },
    "uag_band": "negative",
    "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.",
    "formula_expression": "urine_anion_gap_mmol_l = urine_sodium_mmol_l + urine_potassium_mmol_l - urine_chloride_mmol_l",
    "urine_sodium_mmol_l": 20,
    "urine_chloride_mmol_l": 90,
    "urine_anion_gap_mmol_l": -40,
    "urine_potassium_mmol_l": 30
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/urine-anion-gap-calculator-batlle-1988-d78ad133/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)
