Potatoes and grain
298 kcal estimated (345 kcal ref · 235 g vs 244 g)
P 5.9 g · C 48.8 g · F 9.1 g · 3 items · USDA #2709402 + AI fallback
Caveat: the model called the quinoa couscous. Review food identity as well as the total.
Inspect saved JSON →One request returns detected foods, estimated edible grams, calories, protein, carbs, fat, and USDA FoodData Central provenance in typed JSON. Start with $5 for 500 prepaid scans by card, or pay 0.01 USDC per call over x402. No subscription.
Every response separates items, estimated grams, macros, and USDA FoodData Central IDs (or marks AI fallback when USDA has no match). Below are saved benchmark outputs alongside measured-reference calories so you can judge both structure and real-world limits before buying.
298 kcal estimated (345 kcal ref · 235 g vs 244 g)
P 5.9 g · C 48.8 g · F 9.1 g · 3 items · USDA #2709402 + AI fallback
Caveat: the model called the quinoa couscous. Review food identity as well as the total.
Inspect saved JSON →
354 kcal estimated (292 kcal ref · 300 g vs 292 g)
P 15.0 g · C 33.4 g · F 18.5 g · 3/3 USDA (#172187, #2709402, #2709883)
Caveat: reference includes sweet potato and oil. Photos can miss preparation details.
Inspect saved JSON →
212 kcal estimated (153 kcal ref · 65 g vs 65 g)
P 11.9 g · C 0.0 g · F 17.9 g · 1/1 USDA (#2705852)
Caveat: matched a fattier beef cut than the reference. Review matched food and grams before logging.
Inspect saved JSON →Nutrition5k, Thames et al., CC BY 4.0. Images unchanged. Machine-readable example catalog · Full benchmark and limits.
Buy prepaid scan credits through Stripe (tax included, no subscription, unused credits never expire). One credit pays for one successful analysis across REST or MCP; failed scans and no-food photos (422) return the reserved credit automatically.
| Pack | Price (USD, tax incl.) | Scans | Per scan | Savings |
|---|---|---|---|---|
pack_500 | $5 | 500 | $0.0100 | Base rate |
pack_3000 | $25 | 3,000 | $0.0083 | 17% off |
pack_7000 | $50 | 7,000 | $0.0071 | 29% off |
pack_16000 | $100 | 16,000 | $0.0063 | 38% off |
Idempotency-Key atomically before sending and streams JSON over stdin so large photos never hit argv limits# Atomically publish one request ID per intended scan (reuse on retry; delete only for a fresh paid scan).
TMP=$(mktemp lunch.jpg.reqid.XXXXXX)
uuidgen > "$TMP" && ln "$TMP" lunch.jpg.reqid 2>/dev/null || true
rm -f "$TMP"
REQ_ID=$(cat lunch.jpg.reqid)
(printf '{"image_base64":"'; base64 < lunch.jpg | tr -d '\r\n'; printf '","mime_type":"image/jpeg"}') \
| curl -i https://kcalsnap.com/api/v1/analyze \
-H "Authorization: Bearer $KCALSNAP_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $REQ_ID" \
--data-binary @-
import base64, json, os, urllib.request, uuid
from pathlib import Path
photo = Path("lunch.jpg")
id_file = photo.with_suffix(photo.suffix + ".reqid")
if not id_file.exists():
tmp = id_file.with_name(f"{id_file.name}.{os.getpid()}.{uuid.uuid4().hex}.tmp")
tmp.write_text(str(uuid.uuid4()), encoding="ascii")
try:
os.link(tmp, id_file)
except FileExistsError:
pass
finally:
tmp.unlink(missing_ok=True)
request_id = id_file.read_text(encoding="ascii").strip()
image_b64 = base64.b64encode(photo.read_bytes()).decode("ascii")
req = urllib.request.Request(
"https://kcalsnap.com/api/v1/analyze",
data=json.dumps({
"image_base64": image_b64,
"mime_type": "image/jpeg",
# Optional: "known_total_grams": 320, "note": "fried in 1 tbsp olive oil, oat milk"
}).encode(),
headers={
"Authorization": f"Bearer {os.environ['KCALSNAP_API_KEY']}",
"Content-Type": "application/json",
"Idempotency-Key": request_id,
},
)
with urllib.request.urlopen(req, timeout=60) as res:
print("Credits left:", res.headers.get("X-Credits-Remaining"))
print(json.dumps(json.loads(res.read()), indent=2))
Idempotency-Key before sending so retries never double-charge)import { linkSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
const photo = "lunch.jpg";
const idFile = `${photo}.reqid`;
const tmp = `${idFile}.${process.pid}.${crypto.randomUUID()}.tmp`;
writeFileSync(tmp, crypto.randomUUID(), "ascii");
try {
linkSync(tmp, idFile);
} catch (e) {
if (e.code !== "EEXIST") throw e;
} finally {
unlinkSync(tmp);
}
const requestId = readFileSync(idFile, "ascii").trim();
const response = await fetch("https://kcalsnap.com/api/v1/analyze", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KCALSNAP_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": requestId,
},
body: JSON.stringify({
image_base64: readFileSync(photo).toString("base64"),
mime_type: "image/jpeg",
}),
});
console.log("Credits left:", response.headers.get("x-credits-remaining"));
console.log(response.status, await response.json());
https://kcalsnap.com/mcp as a custom connector){
"mcpServers": {
"kcalsnap": {
"type": "http",
"url": "https://kcalsnap.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_KCALSNAP_API_KEY"
}
}
}
}
KCALSNAP_API_KEY from your environment)codex mcp add kcalsnap --url https://kcalsnap.com/mcp --bearer-token-env-var KCALSNAP_API_KEY
{
"request_id": "a6f0c1d2-...",
"api_version": "v1",
"dish_name": "Cooked rice",
"items": [{
"name": "Cooked rice",
"query": "cooked white rice",
"estimated_grams": 100,
"model_confidence": 0.92,
"nutrition_source": "usda",
"fdc_id": "2708408",
"matched_name": "Rice, white, cooked, no added fat",
"per_100g": { "kcal": 129, "protein_g": 2.67, "carbs_g": 28, "fat_g": 0.28 },
"nutrition": { "kcal": 129, "protein_g": 2.67, "carbs_g": 28, "fat_g": 0.28 }
}],
"totals": { "kcal": 129, "protein_g": 2.67, "carbs_g": 28, "fat_g": 0.28 },
"estimated_total_grams": 100,
"model": "kcalsnap-vision-1",
"matcher_version": "v8",
"estimate": true,
"processing_ms": 1840
}
Illustrative response excerpt. Credit-funded REST responses also include an X-Credits-Remaining header; MCP calls return _meta["kcalsnap/credits_remaining"]. Full schema in openapi.json.
Want a dependency-free CLI that manages key files, retries, local caching, and checkout links? Use the runnable Node 22+ quickstart. Agents can also generate their own checkout link with POST /api/v1/credits/checkout, a Bearer key (kcs_live_ + 64 lowercase hex chars), {"order_id":"UUID_V4","pack_id":"pack_500"} (pack_id optional, defaults to pack_500; also accepts pack_3000, pack_7000, pack_16000), then hand the returned Stripe checkout_url to the cardholder to complete. Check credits anytime with GET /api/v1/credits/balance or the free MCP check_balance tool.
fdc_id + matched_name) or AI fallback.data:image/...;base64, data URL).en) and Lithuanian (lt).Connect any Streamable HTTP MCP client to:
https://kcalsnap.com/mcp
analyze_food – accepts image_base64, mime_type, optional language, optional known_total_grams, optional note (up to 280 chars of meal context), and idempotency_key. Uses 1 prepaid credit with a Bearer key, or 0.01 USDC via @x402/mcp.check_balance – free tool that reconciles expired reservations and returns credits_remaining, blocked, and test_mode for the configured Bearer key.Tool discovery and check_balance are free.
known_total_grams or noteMeasured total weight: pass optional known_total_grams (1 to 5000 g of edible food, excluding the plate and inedible parts, up to 2 decimals) in REST or MCP. KcalSnap preserves your exact total weight and allocates each detected food's share from the estimated relative proportions (informed by the photo, and by note when also provided), labeling portion_basis as supplied_total + photo_estimated_proportions. Omit when unknown or when only part of the pictured meal was weighed.
Meal context note: pass optional note (up to 280 Unicode characters, e.g. "fried in 1 tbsp olive oil, oat milk") when the user mentioned cooking fats, milk type, sauces, or hidden ingredients a photo cannot show. Both fields are part of the request fingerprint; use a new idempotency key if either changes.
For agents with an authorized Base USDC wallet (EOA wallets, mainnet Base eip155:8453), skip checkout and API keys completely: an unpaid call returns HTTP 402 (or MCP JSON-RPC error -32042) with an x402 v2 payment challenge for 0.01 USDC. Resend with the signed authorization; settlement runs only after a validated food result is saved.
import { closeSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const url = "https://kcalsnap.com/api/v1/analyze";
const photo = "lunch.jpg";
const stateFile = `${photo}.x402.json`; // keep private (mode 0600)
const lockFile = `${stateFile}.lock`;
const body = JSON.stringify({
image_base64: readFileSync(photo).toString("base64"),
mime_type: "image/jpeg",
language: "en",
});
// Serialize signing with an exclusive lock and publish state atomically so
// concurrent runs or retries after a lost response never sign twice.
const lockFd = openSync(lockFile, "wx", 0o600);
let saved;
try {
try {
saved = JSON.parse(readFileSync(stateFile, "utf8"));
} catch (e) {
if (e.code !== "ENOENT") throw e;
const challengeRes = await fetch(url, { method: "POST" });
if (challengeRes.status !== 402) throw Error(`Expected 402, got ${challengeRes.status}`);
const challenge = await challengeRes.json();
const signer = privateKeyToAccount(process.env.AGENT_WALLET_KEY);
const client = new x402Client()
.setSpendControls({ maxAmountPerPayment: "$0.01" })
.register("eip155:8453", new ExactEvmScheme(signer));
const payload = await client.createPaymentPayload(challenge);
saved = {
requestId: crypto.randomUUID(),
paymentSignature: Buffer.from(JSON.stringify(payload)).toString("base64"),
};
const tmp = `${stateFile}.${process.pid}.tmp`;
writeFileSync(tmp, JSON.stringify(saved), { mode: 0o600 });
renameSync(tmp, stateFile);
}
} finally {
closeSync(lockFd);
unlinkSync(lockFile);
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": saved.requestId,
"PAYMENT-SIGNATURE": saved.paymentSignature,
},
body,
});
console.log(response.status, await response.json());
Configure your client's spending policy before enabling automatic payments. For recovery after a lost response, persist the original Idempotency-Key and signed PAYMENT-SIGNATURE. Do not sign a fresh payment for a pending request.
A photo cannot reveal exact portion weight, cooking oil, or hidden ingredients. Use KcalSnap for food logging and meal summaries, not medical nutrition therapy or allergen safety.
Our September 2026 baseline benchmark used matcher v4 on 48 source groups from Nutrition5k (two passes, KcalSnap baseline model):
| Measure | Observed result (historical v4 baseline) |
|---|---|
| Calories within 25% of reference | 50.0% of 96 outcomes |
| Median absolute calorie percentage error | 25.1% |
| Mean absolute calorie error | 103 kcal |
| Warm nutrition-pipeline median / p95 | 2.04 s / 3.36 s |
Production now uses matcher v8 and a bundled local USDA FoodData Central table (removing external FDC network hops). The table above records the historical v4 baseline, not a new v8 accuracy claim. Read the separate DFood weighed-photo benchmark (matcher v7) and the Nutrition5k matcher audit. model_confidence is the model's own rating, not calibrated accuracy.
Keep the request_id from a result or analysis error when emailing hello@kcalsnap.com. Need higher throughput or custom volume? Email us.
| Response | Client / agent action |
|---|---|
| 200 | Save the JSON result and read X-Credits-Remaining (or PAYMENT-RESPONSE for x402). |
| 400 / 413 / 415 | Fix the input. No credit or payment is consumed. |
| 402 | Out of credits (top up at /developers/credits/) or x402 payment challenge. |
| 409 | If in_progress, retry unchanged. If idempotency_conflict, keep the original request parameters with that key. |
| 410 | The 24-hour server result recovery window has expired. |
| 422 | No food detected. No credit or payment is consumed. |
| 429 | Capacity, repeated-failure, or spend limit reached. Respect Retry-After; no credit or payment is consumed. |
503 payment_pending | x402 only: wait 60 seconds and retry the exact image, key, and signed authorization. Do not pay again. |
Shared API capacity: 5,000 new analyses per rolling 24 hours globally, 600 per hour globally, 2,000 per API key or wallet per day, and 20 concurrent analyses (up to 10 per key). Within those totals, x402 has a shared allowance of 200 per rolling day, 30 per hour, and 3 concurrent jobs. After 25 unsuccessful analyses per key/wallet in a rolling day (excluding upstream provider rejections), new requests pause temporarily. Completed results can still be replayed free for 24 hours.
KcalSnap does not store submitted images. Photos are sent to OpenRouter and its Gemini provider for recognition; food nutrition lookups run locally against a bundled copy of USDA FoodData Central. Completed result text is kept for 24 hours for safe retries, then purged on later API activity. Request fingerprints and payment records are kept for accounting and retry safety. See our privacy policy.
Card payments are processed by Stripe. KcalSnap stores only SHA-256 key fingerprints, credit balances, and order records – never raw API keys or card numbers. Refunds or disputes pause the affected key for support review. Crypto payments are facilitated by PayAI on Base mainnet. For billing or recovery help, email hello@kcalsnap.com with your request ID, Stripe receipt, or transaction hash – never your API key or private key.