For the complete documentation index, see llms.txt. This page is also available as Markdown.

Image Recognition

Extract foods and ingredients from an uploaded image. This endpoint can recognize images of barcodes as well.

We recommend resizing images to 500px (maintaining aspect ratio) for this endpoint.

Extract Foods from Image (Auto-Typed) — Recommended

post

The recommended camera-to-food endpoint. Takes one image, figures out what kind of food content is in the frame — a packaged product, a barcode / UPC, a raw / cooked dish, or a combination — and runs the right extraction path automatically. Returns Passio-linked ingredients in a single round-trip.

Use this when

  • A user wants to point their camera at food and log it: "I want to send an image and get back all the food items in it for logging" — this is the route to call.

  • You don't know in advance whether the photo is a packaged product, a barcode, or a plate of food.

  • You want one call instead of the legacy "detect → link" two-step (see deprecated detectIngredientsFromImages).

For specialised cases, use extractPackagedProduct (full nutrition-label / barcode parse) or extractFoodAndIngredients (when you specifically want the meal-structured response).

Input / output

  • Body: AdvisorIncomingVisionRequest with a base64 data URI in image, or multipart/form-data with a binary image under video_file / image / image_file / video / file.

  • Response: array of FC_IngredientExtractOutput (Passio-linked).

Authorizations
AuthorizationstringRequired

Bearer token obtained from POST /v2/token-cache/unified/oauth/token/{YourAPIKey}

Body
imagestringRequired

Base64 encoded image as a data URI. Expected format: 'data:;base64,'. For example: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABA...'. You can generate this from an image file using ImageMagick or similar tools: base64_data=$(base64 <image.jpg) && echo "data:image/jpeg;base64,${base64_data}". Supported formats: JPEG, PNG, WebP, and GIF.

messageobjectOptional

Optional context message or metadata about the image to improve analysis (e.g., {"context": "lunch meal", "dietary_preference": "vegetarian"}).

Responses
200

Successful response

application/json
post
/napi/tools/vision/extractIngredientsAutoTyped

Convert your image to a base64 data URI and send it in the image field:

Example: Sending an image via multipart form-data

Upload a binary file using the field name image:

Use image as the form field name for image uploads and video_file for video uploads.

Understanding the Response

Each recognized item in the response includes:

  • ingredientName, portionSize, weightGrams - the AI's raw recognition output (what the LLM identified and estimated).

  • mealName - the name of the overall meal or dish (e.g. "Fruit Salad", "Chicken Stir Fry"). All items that belong to the same meal share this value.

  • componentName - the sub-group within a meal this item belongs to (e.g. "salad", "dressing"). For simple dishes, all items typically share the same componentName.

  • nutritionPreview - pre-calculated calories, macros, and serving size, mapped to Passio's nutrition database.

  • refCode - a reference code to fetch full nutritional details for the item.

Which fields should I use? The weightGrams field is the AI's raw weight estimate. Passio uses this internally to map the recognition result to the best matching serving size in the nutrition database. The nutritionPreview already reflects this mapping with properly calculated calories and macros for the matched portion.

Unless you are connecting to your own external nutrition database, use nutritionPreview for display and refCode to fetch the full nutritional data model with all available portions and nutrients.

Last updated