Interesse an einer wissenschaftlichen Studie?Mehr erfahren

Core API

Design API

Available

Design turns nutrition goals, restrictions, sensory preferences and molecular constraints into usable recipes or meal plans. It can work from structured fields or from a simple text request.

Endpoint

POST/functions/v1/design

Inputs

  • type: recipe or meal_plan
  • input_mode: structured or unstructured
  • For unstructured mode, a non-empty request_text
  • For meal plans, plan_days and meals_per_day
  • Optional preference, sensory, condition, compound and energy constraints

Returns

  • 202 queued response with job_id and status_url
  • Completed recipe or meal_plan result after polling
  • Optional nutrient analysis and images when requested

Request details

  • Structured requests use explicit fields such as recipe_count, diet, condition, compound_filters, daily_energy_kcal_min and daily_energy_kcal_max.
  • compound_filters items require compound or compound_id plus operator, threshold and unit; scope can be portion or day.
  • image_delivery can be base64, signed_url or none. Omit it when images are not needed.

Response details

  • Poll GET /functions/v1/design?job_id=... until status is completed or failed.
  • Recipe jobs return result.recipe; meal-plan jobs return result.meal_plan.
  • Queued and processing responses include retry_after_seconds in meta when available.

Operational notes

  • Requires x-api-key with the edge:design scope.
  • POST usage is counted and quota headers are returned when available.
  • Condition-based requests may require gender so nutrition rules can be selected correctly.

Examples

Request JSON

{
  "input_mode": "unstructured",
  "type": "recipe",
  "request_text": "High-protein Mediterranean breakfast, gentle on digestion",
  "recipe_count": 1,
  "language": "en"
}

Response JSON

{
  "job_id": "d72f91...",
  "status": "queued",
  "status_url": "https://tirqjzahcinadeulfylj.supabase.co/functions/v1/design?job_id=d72f91..."
}

Code examples

curl -X POST 'https://tirqjzahcinadeulfylj.supabase.co/functions/v1/design' \
  -H 'x-api-key: $MYMOLECULES_API_KEY' \
  -H 'Content-Type: application/json' \
  --data '{  "input_mode": "unstructured",  "type": "recipe",  "request_text": "High-protein Mediterranean breakfast, gentle on digestion",  "recipe_count": 1,  "language": "en"}'