> For the complete documentation index, see [llms.txt](https://tomatopy.pizza/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tomatopy.pizza/docs/core-modules/cooking-operations.md).

# Cooking Operations

The cooking endpoints transform prepared ingredients into sauces and cooked products.

## Simmering

### POST /v1/cook/simmer

Simmer ingredients into a sauce. This is the primary way to turn sliced tomatoes into pizza sauce.

```python
import requests

API_BASE = "https://api.tomatopy.pizza/v1"
HEADERS = {
    "Content-Type": "application/json",
    "X-API-Key": "your-api-key",
    "X-Session-ID": "your-session-id"
}

# Simmer sliced tomatoes into sauce
response = requests.post(f"{API_BASE}/cook/simmer", headers=HEADERS, json={
    "ingredients": [
        {"id": "slc_def456", "name": "tomato", "amount": 400, "unit": "g"},
        {"id": "generic", "name": "garlic", "amount": 3, "unit": "cloves"},
        {"id": "generic", "name": "basil", "amount": 10, "unit": "leaves"}
    ],
    "temperature": 100,
    "duration": "30m"
})
sauce = response.json()

print(sauce["id"])           # "sce_jkl012"
print(sauce["sauce_quality"])  # "optimal"
```

#### Request Body

| Field         | Type    | Required | Description                                                   |
| ------------- | ------- | -------- | ------------------------------------------------------------- |
| `ingredients` | array   | yes      | List of ingredients, each with `id`, `name`, `amount`, `unit` |
| `temperature` | integer | yes      | Temperature in Celsius                                        |
| `duration`    | string  | yes      | Duration (e.g., "30m", "1h", "45m")                           |

#### Ingredient Object

| Field    | Type   | Required | Description                                               |
| -------- | ------ | -------- | --------------------------------------------------------- |
| `id`     | string | yes      | ID from a previous endpoint (e.g., sliced tomato ID)      |
| `name`   | string | yes      | Ingredient name                                           |
| `amount` | number | yes      | Quantity                                                  |
| `unit`   | string | yes      | Unit of measurement (e.g., "g", "ml", "cloves", "leaves") |

## Ingredient Requirements

{% hint style="warning" %}
**Raw tomato IDs silently degrade sauce quality.** Tomatoes must be sliced via `/tomato/slice` before being passed to `/cook/simmer`. The API will not return an error if you pass raw tomato IDs, but the resulting sauce quality will be significantly lower.
{% endhint %}

### Correct Flow: Slice First, Then Simmer

```python
# Step 1: Acquire a tomato
response = requests.post(f"{API_BASE}/tomato/acquire", headers=HEADERS, json={
    "variety": "San Marzano",
    "ripeness": 0.9,
    "weight": 400
})
tomato = response.json()

# Step 2: Slice the tomato (REQUIRED for quality)
response = requests.post(f"{API_BASE}/tomato/slice", headers=HEADERS, json={
    "tomato_ids": [tomato["id"]],
    "method": "dice",
    "size": "medium",
    "consistency": "uniform"
})
sliced = response.json()

# Step 3: Simmer the SLICED tomato
response = requests.post(f"{API_BASE}/cook/simmer", headers=HEADERS, json={
    "ingredients": [
        {"id": sliced["id"], "name": "tomato", "amount": 400, "unit": "g"}
    ],
    "temperature": 100,
    "duration": "30m"
})
good_sauce = response.json()
print(good_sauce["sauce_quality"])  # "optimal"
```

### Incorrect Flow: Raw Tomato Directly to Simmer

```python
# WRONG: Skipping the slice step
response = requests.post(f"{API_BASE}/tomato/acquire", headers=HEADERS, json={
    "variety": "San Marzano",
    "ripeness": 0.9,
    "weight": 400
})
tomato = response.json()

# Passing raw tomato ID directly to simmer -- NO ERROR, but quality degrades
response = requests.post(f"{API_BASE}/cook/simmer", headers=HEADERS, json={
    "ingredients": [
        {"id": tomato["id"], "name": "tomato", "amount": 400, "unit": "g"}
    ],
    "temperature": 100,
    "duration": "30m"
})
bad_sauce = response.json()
print(bad_sauce["sauce_quality"])  # "degraded" -- silently degraded!
```

## Roasting

### POST /v1/cook/roast

Roast ingredients for a different flavor profile. Roasting works well for creating deeper, caramelized flavors.

```python
# Roast tomatoes and garlic
response = requests.post(f"{API_BASE}/cook/roast", headers=HEADERS, json={
    "ingredients": [
        {"id": sliced["id"], "name": "tomato", "amount": 400, "unit": "g"},
        {"id": "generic", "name": "garlic", "amount": 6, "unit": "cloves"}
    ],
    "temperature": 200,
    "duration": "45m"
})
roasted = response.json()

print(roasted["id"])       # "rst_mno345"
print(roasted["type"])           # "roasted"
```

#### Request Body

| Field         | Type    | Required | Description                                 |
| ------------- | ------- | -------- | ------------------------------------------- |
| `ingredients` | array   | yes      | List of ingredients (same format as simmer) |
| `temperature` | integer | yes      | Temperature in Celsius                      |
| `duration`    | string  | yes      | Duration (e.g., "45m", "1h")                |

## Choosing Between Simmer and Roast

| Aspect      | Simmer               | Roast                     |
| ----------- | -------------------- | ------------------------- |
| Temperature | 80-120 C             | 150-250 C                 |
| Duration    | 20m-2h               | 30m-1h                    |
| Result      | Smooth, liquid sauce | Concentrated, caramelized |
| Best for    | Classic marinara     | Deep, rich flavors        |

## Error Handling

```python
# Handle validation errors
response = requests.post(f"{API_BASE}/cook/simmer", headers=HEADERS, json={
    "ingredients": [],  # Empty ingredients list
    "temperature": 100,
    "duration": "30m"
})

if response.status_code == 400:
    error = response.json()
    print(f"Error: {error['message']}")  # "Ingredients list cannot be empty"
```

## Best Practices

1. **Always Slice Tomatoes First**

   Never pass raw tomato IDs to cooking endpoints. The quality degradation is silent and significant.
2. **Use Appropriate Temperatures**

   Simmering should be 80-120 C. Roasting should be 150-250 C. Values outside these ranges may produce unexpected results.
3. **Check the Quality Field**

   ```python
   sauce = response.json()
   if sauce["sauce_quality"] == "degraded":
       print("Warning: Degraded sauce. Did you slice the tomatoes first?")
   ```

## Endpoint Reference

| Endpoint          | Method | Description                   |
| ----------------- | ------ | ----------------------------- |
| `/v1/cook/simmer` | POST   | Simmer ingredients into sauce |
| `/v1/cook/roast`  | POST   | Roast ingredients             |

## Next Steps

* [Pizza Endpoints](/docs/core-modules/pizza-creation-system.md) - Create bases, assemble, and bake pizzas
* [Taste Endpoints](/docs/core-modules/taste-testing-module.md) - Analyze your sauces and dishes
* [Tomato Endpoints](/docs/core-modules/ingredient-manipulation.md) - Go back to ingredient preparation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://tomatopy.pizza/docs/core-modules/cooking-operations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
