---
title: "Predict categories for a product"
method: POST
path: "/predict/category"
tags: ["Predict"]
---

# Predict categories for a product

`POST /predict/category`

Predictions are performed using a neural model.
As input, you can either provide:

- the `barcode` of a product: Robotoff will fetch the product from
  Product Opener and will use this data as inputs to predict categories.
- expected inputs under a `product` key. The neural category model
  accepts the following fields as input: `product_name`, `ingredients_tags`,
  `ocr`, `nutriments`, `image_embeddings`. All fields are optional (but you should at least provide one).

## Request body

- union
  - object
    - `barcode` string, required — The barcode of the product to categorize
    - `server_type` 'off' | 'obf' | 'opff' | 'opf' — The server type (=project) to use, such as 'off' (Open Food Facts), 'obf' (Open Beauty Facts),... Only 'off' is currently supported for category prediction
    - `deepest_only` boolean — If true, only return the deepest elements in the category taxonomy (don't return categories that are parents of other predicted categories)
    - `threshold` number — The score above which we consider the category to be detected
  - object
    - `product` object, required — product information used as model input. All fields are optional, but at least one field must be provided.
      - `product_name` string
      - `ingredients_tags` string[] — the ingredient list, as an ordered list of ingredient tags
      - `image_embeddings` array[] — Embeddings of the 10 most recent product images generated with clip-vit-base-patch32 model. Each item of the list is the embedding of a single image, provided as a list of dimension 512. Shape: (num_images, 512)
        - number[] — a single image embedding
      - `ocr` string[] — A list of string corresponding to the text extracted from the product images with OCR. Each element of the list is the text of a single image, the list order doesn't affect predictions. We use OCR text to detect ingredient mentions and use it as a model input. For optimal results, this field should be provided even if `ingredients_tags` is provided.
      - `nutriments` object — Nutriment values. These fields have exactly the same meaning as those of Product Opener. All fields are optional, only send data for the field for which the value is not missing.
        - `fat_100g` number
        - `saturated-fat_100g` number
        - `carbohydrates_100g` number
        - `sugars_100g` number
        - `fiber_100g` number
        - `proteins_100g` number
        - `salt_100g` number
        - `energy-kcal_100g` number
        - `fruits-vegetables-nuts_100g` number
    - `deepest_only` boolean — If true, only return the deepest elements in the category taxonomy (don't return categories that are parents of other predicted categories)
    - `threshold` number — The score above which we consider the category to be detected

## Response `200`

the category predictions

- object
  - `neural` object[]
    - `value_tag` string, required — The predicted `value_tag`
    - `confidence` number, required — The confidence score of the model

---

[API](https://skmtc.net/openfoodfacts/apis/api-reference.md) · [All operations](https://skmtc.net/openfoodfacts/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openfoodfacts/api-reference/versions/23d26c6d55e6/schema)
