toGrams
Converts any quantity and unit to grams using USDA portion weights or density data. Returns unresolved candidates when exact conversion isn't available.
Instructions
Convert an amount to grams. Mass units are exact. A volume or a count needs either the food's own USDA portion weights, which you get by passing fdcId, or a sourced density row. When neither is available the answer is unresolved with candidates attached, because a cup of flour and a cup of honey do not weigh the same.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unit | Yes | Free text such as 'tbsp', 'cups', 'oz', 'medium'. | |
| fdcId | No | When given, this food's own USDA portion weights are tried before the density table. | |
| quantity | Yes | ||
| ingredientName | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | Yes | ||
| grams | Yes | Null when the conversion could not be sourced. | |
| method | Yes | ||
| unitKind | Yes | ||
| confidence | Yes | ||
| densityRow | Yes | ||
| fdcPortion | Yes | ||
| normalizedUnit | Yes | ||
| densityCandidates | Yes | ||
| portionCandidates | Yes |