Recipe scaling with caller-declared non-linear rules
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
| Field | Type | Required | Description |
|---|---|---|---|
ingredients | array<object>; max 60 items | yes | Ingredients with quantity, unit and optional scaling rule. |
fromServings | number; 0.000001..1000000 | no | Servings the recipe is written for. |
toServings | number; 0.000001..1000000 | no | Servings wanted. |
factor | number; 0.001..1000 | no | Scale factor, instead of fromServings/toServings. |
density | object | no | Default density for displayUnit conversions that cross mass and volume. |
maxRelativeDrift | number; 0..10 | no | Fail 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.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: 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. |
factor | string | no | Scale factor used, 12 significant digits. |
factorBasis | string | no | |
ingredients | array<object> | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always 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
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent