Skip to main content
POST
/
api
/
ml
/
recommend
Get ML Recommendation
curl --request POST \
  --url https://api.example.com/api/ml/recommend \
  --header 'Content-Type: application/json' \
  --data '
{
  "Nutritional similarity": {},
  "Diet compatibility": {},
  "Meal type matching": {},
  "Exclusion logic": {}
}
'
{
  "recommendations": [
    {
      "id": 123,
      "recipe_id": 123,
      "name": "<string>",
      "calories": 123,
      "protein": 123,
      "carbs": 123,
      "fat": 123,
      "similarity_score": 123,
      "meal_types": [
        {}
      ],
      "diet_types": [
        {}
      ],
      "image_url": "<string>",
      "recipe_url": "<string>"
    }
  ]
}
This specific endpoint is not directly implemented. Recipe recommendations are provided through the chat interface and the swap meal endpoint.

How Recommendations Work

SmartEat AI uses a machine learning model to provide personalized recipe recommendations. The system uses:
  • K-Nearest Neighbors (KNN) algorithm for similarity matching
  • Nutritional profile matching based on calories, protein, carbs, and fat
  • Diet type filtering (vegan, vegetarian, high-protein, low-carb, etc.)
  • Meal type compatibility (breakfast, lunch, dinner, snack)
  • User preference learning from your profile tastes and restrictions

Recommendation Features

1. Smart Meal Plan Generation

When you request a meal plan through the chat interface, the AI:
  1. Analyzes your profile (goals, macros, preferences)
  2. Selects recipes that match your nutritional targets
  3. Ensures variety across the week
  4. Respects your dietary restrictions and preferences
  5. Balances meal types according to your meals-per-day setting

2. Recipe Similarity Matching

The ML model finds similar recipes based on:
Nutritional similarity
calculation
Calculates distance in a scaled feature space of calories, protein, carbohydrates, and fat content
Diet compatibility
filter
Ensures recommended recipes match your selected diet types (e.g., vegan, high-protein)
Meal type matching
constraint
Only recommends recipes suitable for the target meal slot (breakfast, lunch, dinner, snack)
Exclusion logic
filter
Prevents recommending recipes already in your current meal plan

Getting Recommendations

You can get personalized recommendations through:

Via Chat Interface

Request via Chat
curl -X POST https://api.smarteat.ai/api/chat/ \
  -H "Authorization: Bearer <token>" \
  -d 'message=Suggest a high-protein breakfast for tomorrow'

Via Swap Endpoint

For direct recipe swapping, use the Swap Meal Recommendation endpoint.

ML Model Architecture

Feature Space

The recommendation engine operates in a scaled feature space:
Feature Scaling
features = [
    'calories',      # Total caloric content
    'protein',       # Protein in grams
    'carbs',         # Carbohydrates in grams  
    'fat'           # Fat in grams
]

# Features are normalized using StandardScaler
# This ensures equal weight across different scales

Similarity Calculation

K-Nearest Neighbors
# Model configuration
n_neighbors = 550  # Search space size (configurable)
metric = 'euclidean'  # Distance calculation method

# The model finds the closest recipes in the scaled feature space
# then filters by diet and meal type constraints

Example Recommendation Flow

Response Schema (Conceptual)

If this endpoint were implemented, it would return:
recommendations
array
Array of recommended recipes

Notes

  • The ML model is loaded on application startup for fast inference
  • Recommendations are personalized based on your complete profile
  • The system learns from your preferences over time
  • Use the Swap Meal endpoint for direct recipe substitutions

Build docs developers (and LLMs) love