Experimental application type
Dynamic AI sites
Describe a website in Rune and let an AI engine generate its HTML pages and JSON APIs. Use Ollama locally, or a signed-in Codex or Copilot CLI.
#!RUNE
# Save a page: /?generation=cafe-v1
# Fresh preview: /?cache=off (does not change saved pages)
@App
name = The Little Rune Cafe
type = dynamic-ai-web
engine = ollama
model = phi4
response_target_seconds = 30
timeout_seconds = 180
cache_seconds = 60
max_concurrent = 2
@Site
title = The Little Rune Cafe
description = A welcoming neighborhood cafe where good coffee meets little ideas.
style = Professional responsive design, deep teal, coral accents, soft gradients and a little glass shine. Use inline CSS and no remote assets.
tone = Warm, concise, honest and helpful.
navigation:
Home at /
Our menu at /menu
@Content/Story
headline = Small cups. Big ideas.
about = We are a fictional cafe made from a descriptive Rune document. All menu information is supplied below.
location = 42 Example Lane
hours = Monday to Saturday, 8am to 5pm
@Data/Menu
+ id = espresso
name = Espresso
price = 3
description = A small, bold coffee.
vegan = true
+ id = oat-latte
name = Oat Latte
price = 5
description = Espresso with smooth oat milk.
vegan = true
+ id = cocoa
name = Hot Cocoa
price = 4
description = A warm chocolate drink with dairy milk.
vegan = false
@Page/home
path = /
description = Create a complete, beautiful cafe homepage using Content/Story and Data/Menu. Include navigation to /menu and a small recommendation form that POSTs JSON preferences to /api/recommend and displays the result. Explain that this is an AI-generated demo, not a real ordering service.
@Page/menu
path = /menu
description = Show every item from Data/Menu as readable menu cards with exact names, prices, descriptions and vegan labels. Include navigation back to /. Do not invent menu items.
@Route/GET /api/menu
response = json
description = Return a JSON object with an items array containing all the exact menu records in Data/Menu. Do not invent records.
@Route/POST /api/recommend
response = json
description = Read preferences from the JSON request body. Choose one suitable item from Data/Menu and return item_id, name and reason as a JSON object. If preferences mention vegan or dairy-free, choose a vegan item. This suggests an item only; it does not place an order or persist changes.
Reading the syntax
- @App type = dynamic-ai-web selects the AI server. engine chooses ollama, codex, or copilot; model selects a compatible model.
- @Site and @Content describe the site, while @Data supplies grounding records. @Page describes a complete generated HTML page at its path.
- @Route/METHOD /path describes a JSON response rather than a run: block. The engine receives path parameters, query and JSON body alongside the public site data.
Dynamic AI sites need a running server and the selected engine. Static hosting and the teaching browser sandbox do not run AI providers. Generated endpoints return data; persistence and transactions require separate application logic.
Choose your engine
Ollama uses its local generation API and defaults to phi4. Codex and Copilot use their authenticated CLIs in temporary workspaces with generation-only controls. When changing engines, remove model = phi4 or choose a model supported by that engine.
Run locally
cargo run -- examples/rune-web/dynamic_ai_web.rune --watch
# http://127.0.0.1:3000/Pages are cached briefly; APIs are generated on each request. Configure cache_seconds, timeout_seconds and max_concurrent in @App. Invalid generated HTML or JSON returns an error. AI content varies by model.
While a page is being generated, Vectrune shows a thinking screen with rotating messages and elapsed time. Cached pages open immediately; failures show a manual retry button. The server logs generation timings and cache hits.
Save a page with ?generation=cafe-v1 and revisit that URL after a restart. Use ?cache=off for a fresh preview without changing saved versions. Use a new key to save a different version. API responses remain live.
Set response_target_seconds in @App to recommend how quickly the AI should respond. The thinking screen shows this advisory target; timeout_seconds remains the hard deadline.
Try a CLI demo
Install and sign in to the matching CLI, then run one example at a time. Each uses the CLI default model.
cargo run -- examples/rune-web/dynamic_ai_web_codex.rune --watch
# or
cargo run -- examples/rune-web/dynamic_ai_web_copilot.rune --watch