Public
Weather data → AI-generated art via Open-Meteo + Replicate
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

🎨 Weather Art

Fetches real-time weather data and generates AI art that visualizes current conditions.

How it works

Rendering mermaid diagram...
  1. Weather — Fetches current conditions from Open-Meteo (free, no key needed)
  2. Prompt — Converts temperature, wind, clouds, precipitation, and time-of-day into a vivid scene description
  3. Image — Sends the prompt to Replicate (Stable Diffusion XL) to generate art
  4. Response — Returns the image URL as JSON or a rendered HTML page

Setup

  1. Get a Replicate API token at https://replicate.com/account/api-tokens
  2. Add it as an environment variable: REPLICATE_API_TOKEN

HTTP API

Endpoint: GET /

ParamDefaultDescription
lat40.7128Latitude
lon-74.006Longitude
locationNew YorkLocation name (used in prompt)
formatjsonjson or html

Examples

# JSON response (default)
GET /?location=Tokyo&lat=35.6762&lon=139.6503

# HTML page with rendered image
GET /?location=Paris&lat=48.8566&lon=2.3522&format=html

Cron

cron.ts runs on a schedule (configure in Val Town UI) and stores the latest result in blob storage under the key weather-art-latest.

Files

  • main.ts — HTTP handler (entrypoint)
  • cron.ts — Interval/cron handler
  • shared/weather.ts — Open-Meteo API client
  • shared/prompt.ts — Weather → image prompt builder
  • shared/replicate.ts — Replicate SDXL client