# Compute gram weights for ingredients

{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}

Compute gram weights for ingredient items — convert quantities to grams
using portion data and standard measurement tables.

② of 5 | Next: ④ setRecipeIngredients
Stateless — no recipe needed yet.

Use this to answer: "how many grams is 2 cups of flour?",
"convert 3 eggs to grams", "get gram weight for these ingredients",
"what does 1 pinch of saffron weigh?"

① searchIngredients returns matches with no gram-weight detail — always
follow with this step to resolve a picked ingredient's quantity to
grams. Accepts a batch of (ingredient_id, quantity, unit) items and
returns gram weights.

Pass portion_id (from getIngredient's portions[].id) instead of unit to
resolve a specific portion directly, bypassing unit string matching.
This is the only way to resolve a branded product's default serving,
which has no unit name to match against.

When no portion match exists, returns resolve_options guiding
the caller to either re-call with allow_estimation: true
(system estimate) or ask the user for quantity_grams directly.

Every result carries gram_weight.conversion_source, so a caller can tell
a deterministic gram weight (USDA_FOOD_PORTIONS, USDA_MEASUREMENT_TABLES,
identity) from an estimated one (system_estimate), with the arithmetic in
steps[].reasoning. Both channels read the same field; neither is offered a
different answer for the same policy decision.
