Recipe scaling with caller-declared non-linear rules

$0.005 USDC per call · Business, finance and compliance · POST /api/v1/recipe-scale · Id recipe-scale

Scales up to 60 ingredient quantities by a servings ratio or a factor for an agent resizing a recipe or batch formula, applying per-ingredient rules the caller declares: linear (the labelled default), power exponent, fixed amounts, min/max clamps and rounding steps, with an optional display unit via unit-convert. Reports what rounding did (relative drift, rounds-to-zero). It does NOT know which ingredients should scale non-linearly (spices, leavening, salt, frying oil): no culinary constants are built in, so those rules and any densities come from the caller. It does not judge taste, safety or baking chemistry.

What you get

Doubling or halving a recipe linearly is the default mistake; this applies the caller's own exceptions exactly and shows the rounding damage. 60 ingredients per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/recipe-scale. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/recipe-scale \
  -H 'content-type: application/json' \
  -d '{"fromServings":4,"toServings":6,"ingredients":[{"name":"flour","quantity":240,"unit":"g"},{"name":"eggs","quantity":2,"unit":"each","roundTo":1},{"name":"chili flakes","quantity":1,"unit":"tsp_metric","rule":"power","exponent":0.5}]}'

Input

FieldTypeRequiredDescription
ingredientsarray<object>; max 60 itemsyesIngredients with quantity, unit and optional scaling rule.
fromServingsnumber; 0.000001..1000000noServings the recipe is written for.
toServingsnumber; 0.000001..1000000noServings wanted.
factornumber; 0.001..1000noScale factor, instead of fromServings/toServings.
densityobjectnoDefault density for displayUnit conversions that cross mass and volume.
maxRelativeDriftnumber; 0..10noFail an ingredient when rounding moves it by more than this fraction (0.1 = 10%).

Example request body

{
  "fromServings": 4,
  "toServings": 6,
  "ingredients": [
    {
      "name": "flour",
      "quantity": 240,
      "unit": "g"
    },
    {
      "name": "eggs",
      "quantity": 2,
      "unit": "each",
      "roundTo": 1
    },
    {
      "name": "chili flakes",
      "quantity": 1,
      "unit": "tsp_metric",
      "rule": "power",
      "exponent": 0.5
    }
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
factorstringnoScale factor used, 12 significant digits.
factorBasisstringno
ingredientsarray<object>no
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the creative-games-kit package.

Machine-readable