#!/usr/bin/env bash
# Real demos for P050 "Why OpenRouter Free Models Hit Their Limit So Fast". Runs on the Mac (Docker Desktop):
# the OpenRouter key lives only on the Mac (~/cloudexplainers/.openrouter_api_key), never on render01.
# One container, ce-p050-laptop: a stock Ubuntu 24.04 with curl and jq
# (lab/Dockerfile), Ana's shop scripts in ~/shop. Every command shown is typed into a real interactive bash in a pty
# (demo_driver.py) and sent to the real OpenRouter API.
# Owner rule (2026-11-07): free models only. The key is a free-tier key with a $0 spending limit, so nothing can be charged.
# The driver refuses any output containing the key.
set -euo pipefail
cd "$(dirname "$0")"
P=ce-p050
KEYFILE="$(git rev-parse --show-toplevel)/.openrouter_api_key"
[ -f "$KEYFILE" ] || KEYFILE="$HOME/cloudexplainers/.openrouter_api_key"
cleanup() { docker rm -f $P-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t $P-laptop lab >/dev/null
OPENROUTER_API_KEY=$(cat "$KEYFILE")
export OPENROUTER_API_KEY
docker run -d --name $P-laptop --hostname laptop -e OPENROUTER_API_KEY $P-laptop sleep infinity >/dev/null
python3 - "$P" < demo_driver.py
