Electrolytes / glucose · LIVE
BeAM (bedtime minus AM glucose)
BeAM
Compute BeAM as bedtime glucose minus pre-breakfast (AM) glucose in mg/dL and return the Zisman 2016 analysis category (<0, 0-50, or >50).
Markdown: /docs/beam.md · Canonical: https://magentlab.com/docs/beam
Not a medical device. Not a diagnosis, dose, or listing recommendation.
What it computes
Compute BeAM as bedtime glucose minus pre-breakfast (AM) glucose in mg/dL and return the Zisman 2016 analysis category (<0, 0-50, or >50).
When to use
When an agent needs the published BeAM difference and must not invent a 45 or 55 mg/dL cutoff, order prandial insulin, or diagnose diabetes.
When not to use
- Not a medical device. magent does not diagnose diabetes or order prandial insulin.
- Zisman 2016 analysis categories only: <0, 0-50, and >50 mg/dL. A 45–55 mg/dL range to consider additional intervention is not a hard cutoff in this tool.
- Glucose is caller-supplied. magent does not measure capillary or laboratory glucose.
Formula
beam_mg_dl = bedtime_glucose_mg_dl - am_glucose_mg_dl; mmol/L × 18 → mg/dL; band <0 if beam_mg_dl < 0, 0-50 if 0 <= beam_mg_dl <= 50, >50 if beam_mg_dl > 50
Citation
- Authors
- Zisman A, Morales F, Stewart J, Stuhr A, Vlajnic A, Zhou R
- Source
- BMJ Open Diabetes Res Care. 2016;4(1):e000171
Worked example
Bedtime 180 mg/dL, AM 120 mg/dL
Given:
am_glucose_mg_dl=120bedtime_glucose_mg_dl=180
- BeAM = 180 − 120 = 60.0 mg/dL
- 60.0 > 50 → band >50. Not a prandial insulin order.
Bedtime 10.0 mmol/L, AM 6.67 mmol/L
Given:
am_glucose_mmol_l=6.67bedtime_glucose_mmol_l=10.0
- mg/dL = 10.0 × 18 = 180.0; 6.67 × 18 = 120.06
- BeAM = 180.0 − 120.06 = 59.94 → 59.9 mg/dL, band >50
Also searched as
- BeAM value
- bedtime minus AM glucose
- BeAM Zisman
- bedtime AM differential
- pre-breakfast glucose gap
- BeAM type 2 diabetes
- basal insulin BeAM
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
/api/calc/beam?bedtime_glucose_mg_dl=180&am_glucose_mg_dl=120
Full URL: https://api.magentlab.com/api/calc/beam?bedtime_glucose_mg_dl=180&am_glucose_mg_dl=120
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/beam?bedtime_glucose_mg_dl=180&am_glucose_mg_dl=120"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
bedtime_glucose_mg_dl |
number | optional | Bedtime glucose in mg/dL (40-600). Provide this or bedtime_glucose_mmol_l, not both. Independent of the AM unit. |
bedtime_glucose_mmol_l |
number | optional | Bedtime glucose in mmol/L (2.2-33.3). Converted as mg/dL = mmol/L × 18 (same factor as HOMA-IR). Provide this or bedtime_glucose_mg_dl, not both. |
am_glucose_mg_dl |
number | optional | Pre-breakfast (AM) glucose in mg/dL (40-600). Provide this or am_glucose_mmol_l, not both. Independent of the bedtime unit. |
am_glucose_mmol_l |
number | optional | Pre-breakfast (AM) glucose in mmol/L (2.2-33.3). Converted as mg/dL = mmol/L × 18. Provide this or am_glucose_mg_dl, not both. |
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": [
{
"am_glucose_mg_dl": "120",
"bedtime_glucose_mg_dl": "180"
},
{
"am_glucose_mg_dl": "120",
"bedtime_glucose_mg_dl": "180"
}
]
}
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/beam",
"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": "Zisman A, Morales F, Stewart J, Stuhr A, Vlajnic A, Zhou R",
"doi": "10.1136/bmjdrc-2015-000171",
"id": "zisman-2016",
"pmid": "27110368",
"source": "BMJ Open Diabetes Res Care. 2016;4(1):e000171",
"title": "BeAM value: an indicator of the need to initiate and intensify prandial therapy in patients with type 2 diabetes mellitus receiving basal insulin"
},
"formula": "beam",
"formula_expression": "beam_mg_dl = bedtime_glucose_mg_dl - am_glucose_mg_dl; mmol/L × 18 → mg/dL; band <0 if beam_mg_dl < 0, 0-50 if 0 <= beam_mg_dl <= 50, >50 if beam_mg_dl > 50",
"beam_band": ">50",
"am_glucose_mg_dl": 120.0,
"beam_mg_dl": 60.0,
"bedtime_glucose_mg_dl": 180.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": "Zisman A, Morales F, Stewart J, Stuhr A, Vlajnic A, Zhou R",
"doi": "10.1136/bmjdrc-2015-000171",
"id": "zisman-2016",
"pmid": "27110368",
"source": "BMJ Open Diabetes Res Care. 2016;4(1):e000171",
"title": "BeAM value: an indicator of the need to initiate and intensify prandial therapy in patients with type 2 diabetes mellitus receiving basal insulin"
},
"formula": "beam",
"formula_expression": "beam_mg_dl = bedtime_glucose_mg_dl - am_glucose_mg_dl; mmol/L × 18 → mg/dL; band <0 if beam_mg_dl < 0, 0-50 if 0 <= beam_mg_dl <= 50, >50 if beam_mg_dl > 50",
"beam_band": ">50",
"am_glucose_mg_dl": 120.0,
"beam_mg_dl": 60.0,
"bedtime_glucose_mg_dl": 180.0
}
]
}
Response
| Field | Type | Description |
|---|---|---|
formula |
string | beam |
formula_expression |
string | Exact expression used |
bedtime_glucose_mg_dl |
number | Bedtime glucose in mg/dL (mmol/L × 18 when supplied as mmol/L), 1 decimal |
am_glucose_mg_dl |
number | Pre-breakfast glucose in mg/dL (mmol/L × 18 when supplied as mmol/L), 1 decimal |
beam_mg_dl |
number | BeAM in mg/dL (bedtime minus AM), 1 decimal |
beam_band |
string | Zisman 2016 analysis category: <0, 0-50, or >50 mg/dL. 0 and 50 are 0-50. Not a 45 or 55 cutoff. |
citation |
object | Zisman et al. 2016 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": "Zisman A, Morales F, Stewart J, Stuhr A, Vlajnic A, Zhou R",
"doi": "10.1136/bmjdrc-2015-000171",
"id": "zisman-2016",
"pmid": "27110368",
"source": "BMJ Open Diabetes Res Care. 2016;4(1):e000171",
"title": "BeAM value: an indicator of the need to initiate and intensify prandial therapy in patients with type 2 diabetes mellitus receiving basal insulin"
},
"formula": "beam",
"formula_expression": "beam_mg_dl = bedtime_glucose_mg_dl - am_glucose_mg_dl; mmol/L × 18 → mg/dL; band <0 if beam_mg_dl < 0, 0-50 if 0 <= beam_mg_dl <= 50, >50 if beam_mg_dl > 50",
"beam_band": ">50",
"am_glucose_mg_dl": 120.0,
"beam_mg_dl": 60.0,
"bedtime_glucose_mg_dl": 180.0
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_beam |
BeAM needs bedtime and pre-breakfast glucose (each as mg/dL or mmol/L), as used in Zisman 2016. Returned before settlement; you are not charged. |
| 400 | invalid_bedtime_glucose |
bedtime_glucose_mg_dl (40-600) or bedtime_glucose_mmol_l (2.2-33.3) is required. Returned before settlement; you are not charged. |
| 400 | invalid_am_glucose |
am_glucose_mg_dl (40-600) or am_glucose_mmol_l (2.2-33.3) is required. 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
- HOMA-IR — Compute the Matthews 1985 HOMA-IR approximation from fasting plasma glucose and insulin.
- A1C ↔ eAG — Convert A1C percent to estimated average glucose, or the reverse, using Nathan/ADAG.
- Bang diabetes screening — Sum the Bang 2009 Table 2 development screening score for undiagnosed diabetes and return high_risk when the total is ≥5.
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.