calculate_macros
Calculate exact macros and calories for a specified food portion. Provide food name, amount, and unit to get protein, carbs, fat, and calorie values from USDA data.
Instructions
Calculate exact macros and calories for a specific portion of one food.
All arithmetic happens in Python. Do not compute these numbers yourself.
Args:
name: The food name. Resolved the same way as get_food.
amount: How much of the food, as a number, e.g. 150 or 2.5.
unit: The unit amount is expressed in, e.g. "g", "oz", "cup", "tbsp".
Case-insensitive and plural-tolerant ("grams" and "Gram" both work).
The unit is converted to the food's native unit when both belong to the
same family: mass (g, kg, oz, lb) or volume (ml, tsp, tbsp, fl_oz,
quarter_cup, cup). Conversion is REFUSED across families -- grams to
tablespoons needs a density this database does not store -- and refused
for countable units ("large", "slice", "container", "scoop", "half",
"cake", "medium"), which have no fixed mass.Returns: {"food", "amount", "unit", "protein_g", "carb_g", "fat_g", "calories", ...} with calories derived as protein4 + carb4 + fat*9.
On an unknown food: {"error": "food_not_found", "suggestions": [...]}.
On an impossible conversion: {"error": "unit_mismatch", "native_unit": ...}
naming the unit the food is actually stored in -- retry with that unit.
Negative amounts return {"error": "invalid_amount"}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| unit | Yes | ||
| amount | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||