# Process Ai Food

Use the `processAiFood` mutation to generate a food analysis from text or image that can be registered on the food log.

## Arguments

| Argument                | Type               | Description                                   |
| ----------------------- | ------------------ | --------------------------------------------- |
| `input`                 | ProcessAIFoodInput |                                               |
| `input.image`           | Upload             | Food image to be processed.                   |
| `input.foodDescription` | String             | Text description of the food to be processed. |

## Available Fields

|                |              |                                                                                  |
| -------------- | ------------ | -------------------------------------------------------------------------------- |
| `success`      | Boolean      | **True** if the food has been processed. Otherwise, it displays **False.**       |
| `message`      | String       | Description of the result.                                                       |
| `foodAnalysis` | FoodAnalysis | [Food analysis object.](/graphql/objects/food-logs/ai-food-log/food-analysis.md) |

## Example using Image Analysis

Because it is not possible to upload files in the GraphQL playground, the following example can be executed on tools like postman.

{% tabs %}
{% tab title="cURL" %}

```graphql
curl --location 'https://production.suggestic.com/graphql' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ8.eyJleHAiOjE3NTAzNzcxODQsInVpZCI5ImY1NDc2MjI2LThlNTQtNGUwNC1hY2IwLWExZjdiMmhMzBhMyIsInBpZCI6IjIyOWQ4OTc4LTRlYmItNGFmZi1hNTc0LTM4MDk3Y2UwM2YyZCIsImlzcyI6InNnOmFwcCIsImF1ZCI6InNnOnVzZXIiLCJpYXQiOjE3NDkxNjc1ODQsImNhdCI6IjIwMjUwNDI1MTkxNSIsImFwcCI6ImF0dGFuZS1oZWFsdGgiLCJ0eXBlIjoiYWNjZXNzIn0.ZINEA-A39crTB96rzBwc7ebahANNGVqe4Pn7PA4SbJw' \
--header 'X-APOLLO-OPERATION-NAME: processFoodImageAssistant' \
--form 'operations="{
  \"operationName\": \"processAiFood\",
  \"query\": \"mutation processAiFood(\$image: Upload, \$foodDescription: String) { processAiFood(input: { image: \$image, foodDescription: \$foodDescription }) { message success foodAnalysis { id status serviceResponse } } }\",
  \"variables\": {
    \"image\": null,
    \"foodDescription\": \"\"
  }
}"' \
--form 'map="{\"0\":[\"variables.image\"]}"' \
--form '0=@"/Users/user/Downloads/balanced-diet.jpg"'
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
    "data": {
        "processAiFood": {
            "message": "AI Food Log Processed",
            "success": true,
            "foodAnalysis": {
                "id": "Rm9vZEFuYWx5c2lzOjY3ZWM0NWE3LTc3ZWQtNGY1My1iNjVkLTMyNzYwMGI2ZjgxNA==",
                "status": "COMPLETED",
                "serviceResponse": "{\"id\": \"67ec45a7-77ed-4f53-b65d-327600b6f814\", \"data\": {\"food_name\": \"Healthy Chicken & Chickpea Power Bowl\", \"nutritional_information\": {\"nutrients\": [{\"name\": \"calories\", \"value\": 572.0, \"unit\": \"kcal\"}, {\"name\": \"protein\", \"value\": 49.0, \"unit\": \"g\"}, {\"name\": \"fat\", \"value\": 19.0, \"unit\": \"g\"}, {\"name\": \"carbs\", \"value\": 55.0, \"unit\": \"g\"}]}, \"analysis_results\": {\"summary\": \"A vibrant and nutritious power bowl featuring lean cooked chicken breast, a variety of fresh and cooked vegetables, and protein-rich chickpeas. The bowl includes sliced avocado, halved cherry tomatoes, shredded carrots, mixed leafy greens (such as lettuce and arugula), steamed broccoli and cauliflower florets, and sliced red bell pepper. It is lightly seasoned with black sesame seeds.\", \"ingredients\": [{\"name\": \"chicken breast (cooked)\", \"quantity\": 110.0, \"unit\": \"g\"}, {\"name\": \"avocado\", \"quantity\": 75.0, \"unit\": \"g\"}, {\"name\": \"cherry tomatoes\", \"quantity\": 50.0, \"unit\": \"g\"}, {\"name\": \"mixed greens\", \"quantity\": 60.0, \"unit\": \"g\"}, {\"name\": \"carrots (shredded)\", \"quantity\": 60.0, \"unit\": \"g\"}, {\"name\": \"chickpeas (cooked)\", \"quantity\": 110.0, \"unit\": \"g\"}, {\"name\": \"broccoli (steamed)\", \"quantity\": 55.0, \"unit\": \"g\"}, {\"name\": \"cauliflower (steamed)\", \"quantity\": 55.0, \"unit\": \"g\"}, {\"name\": \"red bell pepper\", \"quantity\": 45.0, \"unit\": \"g\"}, {\"name\": \"black sesame seeds\", \"quantity\": 1.0, \"unit\": \"g\"}]}}}"
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

Note:\
This mutation requires an AI specific header (already included on the cURL):\
`X-APOLLO-OPERATION-NAME: processFoodImageAssistant`

## Example with Text Analysis

Executed in the GraphQL playground

{% tabs %}
{% tab title="Request" %}

<pre class="language-graphql"><code class="lang-graphql">mutation{
<strong>  processAiFood(
</strong>    input:{
      foodDescription:"3 eggs, two pieces of whole grain bread, half avocado with lime and a pinch of salt and two beef sausages"
    }
  ){
    success
    message
    foodAnalysis{
      id
      status
      errorMessage
      serviceResponse
      foodDescription
    }
  }
}
</code></pre>

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "processAiFood": {
      "success": true,
      "message": "AI Food Log Processed",
      "foodAnalysis": {
        "id": "Rm9vZEFuYWx5c2lzOjI0MjRkNDRjLTA2N2YtNGQ1Mi05Yjg0LWU3NTc3ODMxZWU0OQ==",
        "status": "COMPLETED",
        "errorMessage": null,
        "serviceResponse": "{\"id\": \"2424d44c-067f-4d52-9b84-e7577831ee49\", \"data\": {\"food_name\": \"Hearty Breakfast Plate\", \"nutritional_information\": {\"nutrients\": [{\"name\": \"calories\", \"value\": 904.0, \"unit\": \"kcal\"}, {\"name\": \"protein\", \"value\": 54.0, \"unit\": \"g\"}, {\"name\": \"fat\", \"value\": 62.0, \"unit\": \"g\"}, {\"name\": \"carbs\", \"value\": 43.0, \"unit\": \"g\"}]}, \"analysis_results\": {\"summary\": \"This meal is a substantial breakfast featuring three pan-fried eggs, two slices of toasted whole grain bread, half an avocado seasoned with lime and salt, and two pan-fried beef sausages. It is rich in protein and fats, with a moderate amount of carbohydrates from the bread and avocado.\", \"ingredients\": [{\"name\": \"egg\", \"quantity\": 150.0, \"unit\": \"g\"}, {\"name\": \"whole grain bread\", \"quantity\": 60.0, \"unit\": \"g\"}, {\"name\": \"avocado\", \"quantity\": 100.0, \"unit\": \"g\"}, {\"name\": \"lime juice\", \"quantity\": 5.0, \"unit\": \"ml\"}, {\"name\": \"salt\", \"quantity\": 1.0, \"unit\": \"g\"}, {\"name\": \"beef sausage\", \"quantity\": 100.0, \"unit\": \"g\"}]}}}",
        "foodDescription": "3 eggs, two pieces of whole grain bread, half avocado with lime and a pinch of salt and two beef sausages"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suggestic.com/graphql/query/mutations/food-log/ai-food-log/process-ai-food.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
