# A-a Gradient Calculator (Alveolar-Arterial Oxygen Gradient)

> A-a Gradient Calculator (Alveolar-Arterial Oxygen Gradient) 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-14).

Computes the alveolar–arterial oxygen gradient using the simplified alveolar gas equation given FiO2, barometric pressure, PaCO2, PaO2, and respiratory quotient

## Facts

- Endpoint: GET https://api.magentlab.com/api/calc/aa_gradient
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/a-a-gradient-calculator-alveolar-arterial-oxygen-gradient-410a267a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_jvoPxGorvfHD1hP1_e3zV

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 a-a-gradient-calculator-alveolar-arterial-oxygen-gradient-410a267a
```

Example prompt: Calculate the A-a oxygen gradient for a patient on room air (FiO2 0.21) with a PaCO2 of 40 mm Hg and a PaO2 of 80 mm Hg at standard barometric pressure of 760 mm Hg using an RQ of 0.8.

## When to prefer this

Use this endpoint when you need a fast, deterministic, citeable A-a gradient computation from raw arterial blood gas values. Prefer it over manual calculation or LLM arithmetic to avoid rounding errors and to get a traceable citation. It is ideal for clinical decision-support pipelines, EHR automation, and educational tools that require reproducible pulmonary physiology math.

## Known failure modes

- PaCO2 or PaO2 out of accepted range (8–80 and 20–700 mm Hg respectively) returns a validation error
- FiO2 outside 0.21–1.0 range rejected
- Barometric pressure outside 500–800 mm Hg range rejected
- RQ outside 0.7–1.0 range rejected
- Missing required parameters (paco2_mm_hg or pao2_mm_hg) returns 400 error
- Payment not settled via x402 returns 402 Payment Required

## How this service works

Alveolar–arterial oxygen gradient from FiO2, barometric pressure, PaCO2, PaO2, and RQ using the simplified alveolar-gas equation (PH2O 47 mm Hg). Deterministic published arithmetic with citation; not a diagnosis.

## Output

Returns the computed alveolar oxygen tension (PAO2), the A-a gradient in mm Hg (PAO2 − PaO2), and interpretive reference context including citation to the published formula. All values are deterministic arithmetic; no diagnosis is rendered.

## 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": [
      "paco2_mm_hg",
      "pao2_mm_hg"
     ],
     "properties": {
      "rq": {
       "type": "number",
       "description": "Respiratory exchange ratio R (0.7-1.0). Omitted uses 0.8."
      },
      "fio2": {
       "type": "number",
       "description": "Inspired oxygen as a fraction (0.21-1.0), not a percent. Omitted uses 0.21 (room air)."
      },
      "pb_mm_hg": {
       "type": "number",
       "description": "Barometric pressure in mm Hg (500-800). Omitted uses 760."
      },
      "pao2_mm_hg": {
       "type": "number",
       "description": "Arterial PO2 in mm Hg (20-700)."
      },
      "paco2_mm_hg": {
       "type": "number",
       "description": "Arterial PCO2 in mm Hg (8-80)."
      }
     }
    }
   },
   "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/aa_gradient",
  "count": 2,
  "items": [
   {
    "rq": 0.8,
    "fio2": 0.21,
    "formula": "aa_gradient",
    "citation": {
     "id": "riley-cournand-1949",
     "doi": "10.1152/jappl.1949.1.12.825",
     "title": "\"Ideal\" alveolar air and the analysis of ventilation-perfusion relationships in the lungs",
     "source": "J Appl Physiol. 1949;1(12):825-847",
     "authors": "Riley RL, Cournand A"
    },
    "pb_mm_hg": 760,
    "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.",
    "pao2_mm_hg": 95,
    "paco2_mm_hg": 40,
    "aa_gradient_mm_hg": 4.7,
    "water_vapor_mm_hg": 47,
    "formula_expression": "PAO2_mm_hg = fio2 * (pb_mm_hg - 47) - paco2_mm_hg / rq; aa_gradient_mm_hg = PAO2_mm_hg - pao2_mm_hg",
    "pao2_alveolar_mm_hg": 99.7
   },
   {
    "rq": 0.8,
    "fio2": 0.21,
    "formula": "aa_gradient",
    "citation": {
     "id": "riley-cournand-1949",
     "doi": "10.1152/jappl.1949.1.12.825",
     "title": "\"Ideal\" alveolar air and the analysis of ventilation-perfusion relationships in the lungs",
     "source": "J Appl Physiol. 1949;1(12):825-847",
     "authors": "Riley RL, Cournand A"
    },
    "pb_mm_hg": 760,
    "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.",
    "pao2_mm_hg": 95,
    "paco2_mm_hg": 40,
    "aa_gradient_mm_hg": 4.7,
    "water_vapor_mm_hg": 47,
    "formula_expression": "PAO2_mm_hg = fio2 * (pb_mm_hg - 47) - paco2_mm_hg / rq; aa_gradient_mm_hg = PAO2_mm_hg - pao2_mm_hg",
    "pao2_alveolar_mm_hg": 99.7
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/a-a-gradient-calculator-alveolar-arterial-oxygen-gradient-410a267a/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)
