# Recipe H — Multi-modal news roundup

# Recipe H — Multi-modal news roundup

**Outcome:** A `roundup.json` file with 5 top headlines on a topic, each
paired with a generated editorial illustration. Render it however you want
(static page, daily email, RSS feed).

**Approx cost:** ~$0.21 per roundup.

## Script

```bash
#!/bin/bash
set -euo pipefail

TOPIC="${1:-developments in space exploration}"

# 1. Pull recent headlines via a search-capable LLM
visa-cli run-llm --json --yes \
    --model or-perplexity-sonar \
    "Top 5 recent headlines about $TOPIC. Return strict JSON array: [{\"title\":\"...\",\"summary\":\"...\"}]" \
  | jq -r '.text' \
  | jq -c '.[]' > stories.ndjson

# 2. For each story, generate an editorial illustration
rm -f roundup.ndjson
while IFS= read -r story; do
  TITLE=$(echo "$story" | jq -r .title)

  IMG=$(visa-cli generate image \
      "editorial illustration for: $TITLE" \
      --json --yes \
      | jq -r '.urls[0] // .filePath')

  echo "$story" | jq --arg img "$IMG" '. + {image: $img}' >> roundup.ndjson
done < stories.ndjson

# 3. Bundle into a single JSON array
jq -s '.' < roundup.ndjson > roundup.json
rm stories.ndjson roundup.ndjson

echo "Roundup ready: $(jq '. | length' roundup.json) stories in roundup.json"
```

## Cost breakdown

| Step | Tool | Approx |
|---|---|---|
| Headlines | `or-perplexity-sonar` | $0.01 |
| Illustrations (5 × $0.04) | `fal-flux-pro` | $0.20 |
| **Total** | | **~$0.21** |

## Variations

- **Daily cron** — wrap in a cron job that emails the JSON / rendered HTML
  every morning.
- **Per-illustration prompt tuning** — pass the story summary to
  `run-llm` first to draft a tailored image prompt before sending to
  `generate image`.
- **RSS / Atom feed** — feed `roundup.json` into a tiny templating step.
