Loki Docs
Tools › Foods › Create a custom food

Create a custom food

create_custom_foodAdds
What it does
Adds a new record and leaves what you had alone. Safe to retry: the same call twice changes nothing more.
Permission
Foods, change foods:write

What your assistant is told

Create a reusable custom food when the user has a specific item not in Open Food Facts. Provide macros PER 100 g (energy in kcal, the rest in grams). serving is an optional human label like "1 cup (240 g)". Returns the food with its id for use in log_meal. Pass a stable idempotency_key so a retry doesn't create duplicates. A food created here lands in the user's MY INGREDIENTS list, so list_my_ingredients finds it next time instead of you estimating it again. Set from_label when you read these values off a nutrition-label photo they shared — that is what marks the row as label-added. The photo itself is never sent to this server; only the numbers you read are.

Parameters

  • nametext, requiredFood name, e.g. "Grandma's granola".
  • energy_kcalwhole number, requiredEnergy per 100 g, in kcal.
  • protein_gnumber, requiredProtein per 100 g, in grams.
  • carb_gnumber, requiredCarbohydrate per 100 g, in grams.
  • fat_gnumber, requiredFat per 100 g, in grams.
  • idempotency_keytext, requiredIdempotency key; reuse on retry to avoid duplicates.
  • fiber_gnumber, optionalOptional fiber per 100 g, in grams.
  • servingtext, optionalOptional serving label, e.g. "1 cup (240 g)".
  • serving_gramswhole number, optionalOptional grams in one serving.
  • from_labeltrue or false, optionalTrue when you read these values off a nutrition-label photo the user shared. Marks the food as label-added in My ingredients. Default false.