# Transtubular Potassium Gradient (TTKG) Calculator

> Transtubular Potassium Gradient (TTKG) Calculator 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).

Computes the transtubular potassium gradient (TTKG) from plasma potassium, urine potassium, plasma osmolality, and urine osmolality using the Ethier 1990 formula.

## Facts

- Endpoint: GET https://api.magentlab.com/api/calc/ttkg
- 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/transtubular-potassium-gradient-ttkg-calculator-82c07252
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_HB7i4AaEU3goDVag3awbX

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 transtubular-potassium-gradient-ttkg-calculator-82c07252
```

Example prompt: Calculate the TTKG for a patient with a plasma potassium of 6.2 mmol/L, urine potassium of 80 mmol/L, plasma osmolality of 290 mOsm/kg, and urine osmolality of 620 mOsm/kg.

## When to prefer this

Use this endpoint when you need a fast, formula-based computation of the TTKG from four standard electrolyte lab values (Ethier 1990 method), particularly during hyperkalemia or hypokalemia workup to assess renal potassium handling. It is appropriate when urine osmolality exceeds plasma osmolality (antidiuretic state); do not use during water diuresis. Prefer this over general-purpose LLM math for reproducibility and guaranteed one-decimal precision.

## Known failure modes

- Urine osmolality not greater than plasma osmolality (water diuresis state) — result is invalid and may be rejected
- Out-of-range plasma potassium (outside 1.5–8.0 mmol/L) causes validation error
- Out-of-range urine potassium (outside 1–200 mmol/L) causes validation error
- Plasma osmolality outside 240–400 mOsm/kg causes validation error
- Urine osmolality outside 50–1400 mOsm/kg causes validation error
- Missing any required query parameter returns an error
- Payment failure (x402) if USDC balance is insufficient

## How this service works

Transtubular potassium gradient (TTKG) from plasma potassium, urine potassium, plasma osmolality, and urine osmolality (Ethier JH et al., Am J Kidney Dis 1990). TTKG = (urine_k / potassium) / (urine_osm / plasma_osm), 1 decimal. Not valid when urine osmolality is not greater than plasma osmolality (water diuresis). Numeric TTKG only; not a potassium-disorder diagnosis or medical device.

## Output

Returns a single numeric TTKG value rounded to one decimal place, computed as (urine_k / plasma_k) / (urine_osm / plasma_osm). The result reflects tubular handling of potassium in the collecting duct; the endpoint does not provide a clinical diagnosis or interpretation of potassium disorders.

## 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": [
      "potassium_mmol_l",
      "urine_k_mmol_l",
      "plasma_osm_mosm_kg",
      "urine_osm_mosm_kg"
     ],
     "properties": {
      "urine_k_mmol_l": {
       "type": "number",
       "description": "Urine potassium in mmol/L (1-200)."
      },
      "potassium_mmol_l": {
       "type": "number",
       "description": "Plasma potassium in mmol/L (1.5-8.0)."
      },
      "urine_osm_mosm_kg": {
       "type": "number",
       "description": "Urine osmolality in mOsm/kg (50-1400). Must be greater than plasma_osm_mosm_kg."
      },
      "plasma_osm_mosm_kg": {
       "type": "number",
       "description": "Plasma osmolality in mOsm/kg (240-400)."
      }
     }
    }
   },
   "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/ttkg",
  "count": 2,
  "items": [
   {
    "ttkg": 5,
    "formula": "ethier",
    "citation": {
     "id": "ethier-1990",
     "doi": "10.1016/S0272-6386(12)80076-X",
     "pmid": "2321642",
     "title": "The transtubular potassium concentration in patients with hypokalemia and hyperkalemia",
     "source": "Am J Kidney Dis. 1990;15(4):309-315",
     "authors": "Ethier JH, Kamel KS, Magner PO, Lemann J Jr, Halperin ML"
    },
    "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.",
    "urine_k_mmol_l": 40,
    "potassium_mmol_l": 4,
    "urine_osm_mosm_kg": 600,
    "formula_expression": "ttkg = (urine_k_mmol_l / potassium_mmol_l) / (urine_osm_mosm_kg / plasma_osm_mosm_kg)",
    "plasma_osm_mosm_kg": 300
   },
   {
    "ttkg": 5,
    "formula": "ethier",
    "citation": {
     "id": "ethier-1990",
     "doi": "10.1016/S0272-6386(12)80076-X",
     "pmid": "2321642",
     "title": "The transtubular potassium concentration in patients with hypokalemia and hyperkalemia",
     "source": "Am J Kidney Dis. 1990;15(4):309-315",
     "authors": "Ethier JH, Kamel KS, Magner PO, Lemann J Jr, Halperin ML"
    },
    "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.",
    "urine_k_mmol_l": 40,
    "potassium_mmol_l": 4,
    "urine_osm_mosm_kg": 600,
    "formula_expression": "ttkg = (urine_k_mmol_l / potassium_mmol_l) / (urine_osm_mosm_kg / plasma_osm_mosm_kg)",
    "plasma_osm_mosm_kg": 300
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/transtubular-potassium-gradient-ttkg-calculator-82c07252/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)
