All posts
ai guide

AI Product Analysis: Summaries Your Users Can Actually Read

Turn raw label data into a plain-language summary with highlights, warnings, diet compatibility and processing level — for catalog products or your own data.

FoodBase Team 3 min read

The problem with raw nutrition data

Your API response says sugars_g: 56.3. Your user wants to know: is this a lot? Bridging that gap — turning numbers and ingredient lists into something a person can act on — is usually where nutrition apps either invest heavily or give up.

The analysis endpoints do that step for you: one call returns a short, factual, plain-language analysis generated strictly from the product’s data. No invented numbers, no health claims — the model is instructed to say “unknown” rather than guess.

Analyzing a catalog product

POST /v1/analyze/product takes a food_id or barcode (one of the two), costs 1 credit, and answers in any of 6 languages:

curl -X POST "https://foodbase.dev/v1/analyze/product" \
  -H "X-API-Key: food_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"barcode": "3017620422003", "lang": "en"}'
{
  "food_id": "…",
  "lang": "en",
  "cached": false,
  "analysis": {
    "summary": "Nutella is a chocolate hazelnut spread… 539 kcal per 100 g.",
    "highlights": ["Contains 13% hazelnuts"],
    "warnings": ["High in sugar (56.3 g per 100 g)", "Contains milk and tree nuts"],
    "diets": {
      "vegan": "no",
      "vegetarian": "yes",
      "gluten_free": "unknown",
      "lactose_free": "no"
    },
    "processing_level": "ultra_processed",
    "per_serving": "One 15 g serving contains approximately 81 kcal…"
  },
  "disclaimer": "AI-generated from the product's label data…"
}

A few things worth knowing about the shape:

  • diets is deliberately three-valued: yes / no / unknown. The model only commits when the ingredients or allergen data actually supports it — render unknown as a question mark, not a quiet omission.
  • processing_level is a NOVA-style judgement from the ingredients (unprocessedultra_processed, or unknown).
  • disclaimer ships with every response. Show it — the analysis is informational, not medical advice.

Analyses are cached per product and language, so the first caller pays the generation latency and everyone after gets an instant answer — at the same 1-credit price. cached: true tells you which case you hit.

You can see this endpoint rendered on any product page — the “AI analysis” panel is exactly this response.

Analyzing your own product data

What about products that aren’t in the catalog — private-label goods, new launches, internal SKUs? POST /v1/analyze/custom (also 1 credit) accepts the product data in the request body and runs the same analysis:

curl -X POST "https://foodbase.dev/v1/analyze/custom" \
  -H "X-API-Key: food_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Protein bar cocoa",
    "brand": "MyBrand",
    "ingredients": "Oats, whey protein, cocoa, honey",
    "nutrients": { "energy_kcal": 380, "proteins_g": 30, "sugars_g": 18 }
  }'

Two rules keep the output honest:

  • A bare name is rejected (422). You must provide ingredients and/or at least one per-100g nutrient value — otherwise the model would have nothing factual to analyze.
  • Implausible values are rejected, not silently fixed. Nutrient fields have per-100g caps (energy ≤ 900 kcal, grams ≤ 100, sodium ≤ 10000 mg), and unknown nutrient keys are an error rather than being ignored.

The nutrients object takes the standard macros plus a curated set of vitamins and minerals (vitamin C, D, B12, folate, E, calcium, iron, potassium, magnesium, zinc) — give it more and the highlights get sharper: supply calcium and iron values and you’ll get back things like “High in calcium (450 mg/100 g)”.

The response mirrors the catalog analysis, with an input_hash instead of a food_id — identical input hashes identically, so repeat analyses of the same data are cache hits. There’s an optional barcode field too: it isn’t analyzed, it flags the product as one you’d like to see added to the catalog.

Prefer a form to a JSON body? The playground has this exact endpoint as a type-it-in form.

Practical integration notes

  • Language: pass lang (en, fr, es, de, it, bg) and the whole analysis — summary, highlights, warnings — comes back in that language. Each language caches separately.
  • Credits: 1 credit per call, including cache hits. Failures (bad request, provider error, unknown product) refund automatically — you only pay for answers.
  • Idempotency: there is none — a double-submit is two charges. Disable your button while a request is in flight.
  • Rendering: the response is designed to map straight onto UI — summary paragraph, checkmark list, warning list, four diet badges, a processing-level tag. That’s precisely how the product pages here render it.

Try it

Grab a free API key (100 AI credits included), open the docs, or poke at the live panels on any product page.

Build it with FoodBase

6.1M products, 40+ nutrients and AI food analysis — free to start, no credit card.