Interested in joining a scientific study?Learn more

Core API

Decide API

Available

Decide evaluates explicit food, meal, drink or ingredient options using text, image or audio inputs and optional user context.

Endpoint

POST/functions/v1/decide

Inputs

  • inputs[] with one or more text, image or audio entries
  • Each input requires type and data; label and mime_type are optional
  • Optional user_context such as language, diet, condition, compound_filters, preferred_foods or avoided_foods

Returns

  • Synchronous 200 response with status completed
  • result.answer_text with the recommendation
  • Structured failed response for validation or upstream errors

Request details

  • Legacy top-level input_type, data and audio_format fields are not accepted.
  • Text data must be non-empty; image data should be an image URL or supported image data URL; audio data should include mime_type when ambiguous.
  • user_context only accepts documented context fields.

Response details

  • No polling is required for Decide.
  • Successful responses always contain status: completed, result.answer_text and error: null.
  • Failed responses contain status: failed, result: null and an error object.

Operational notes

  • Requires x-api-key with the edge:decide scope.
  • Usage is counted and quota headers are returned when available.
  • The API is scoped to concrete nutrition decisions between explicit options.

Examples

Request JSON

{
  "inputs": [
    {
      "type": "text",
      "label": "meal options",
      "data": "Option A: oatmeal with berries. Option B: croissant and jam."
    }
  ],
  "user_context": {
    "language": "en",
    "notes": "Prefer steady energy"
  }
}

Response JSON

{
  "status": "completed",
  "result": {
    "answer_text": "Choose option A. It is more likely to provide steady energy."
  },
  "error": null
}

Code examples

curl -X POST 'https://tirqjzahcinadeulfylj.supabase.co/functions/v1/decide' \
  -H 'x-api-key: $MYMOLECULES_API_KEY' \
  -H 'Content-Type: application/json' \
  --data '{  "inputs": [    {      "type": "text",      "label": "meal options",      "data": "Option A: oatmeal with berries. Option B: croissant and jam."    }  ],  "user_context": {    "language": "en",    "notes": "Prefer steady energy"  }}'