---
title: "Run Gemini search-grounding and persist (internal testing)"
method: POST
path: "/internal/grounding/search_grounding"
tags: ["internal"]
---

# Run Gemini search-grounding and persist (internal testing)

`POST /internal/grounding/search_grounding`

Requires elevated permissions. Triggers the default search-grounding. Provide either meal_photo_queue_id (full QueueLabelContext + trace) or patient_id (synthetic raw, no MPQ linkage).

## Request body

- GroundingTestSearchGroundingRequest
  - `brand` string, nullable
  - `composite_food_id` string, nullable
  - `food` string, required
  - `grounding_mode` 'cpg' | 'restaurant' | 'whole_food', required
  - `is_composite_food` boolean
  - `meal_photo_queue_id` integer, nullable — When set, builds QueueLabelContext from this MPQ (same as pipeline).
  - `patient_id` integer, nullable — Required when meal_photo_queue_id is omitted; patient used for OpenAI context.
  - `preparation_method` string, nullable — Stored on the synthetic raw (e.g. cpg, restaurant); defaults to grounding_mode.

## Response `200`

successful operation (grounded false if Gemini returned no parseable result)

- GroundingTestSearchGroundingResponse
  - `grounded` boolean, required
  - `grounding_request_id` integer, nullable
  - `message` string, nullable
  - `search_grounding_result` object, nullable
  - `user_provided_nutrition` object, nullable

## Other responses

- `400` — invalid request
- `403` — not authorized
- `404` — patient or meal photo queue not found

---

[API](https://skmtc.dev/rxfoodapp/apis/inneranalytics-mnt-server.md) · [All operations](https://skmtc.dev/rxfoodapp/apis/inneranalytics-mnt-server/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/rxfoodapp/inneranalytics-mnt-server/revisions/0703cbbbefe8/schema)
