Files
apress/deploy/workshop-llm/gen-attendee-keys.sh
T
Omar SobhandClaude Opus 4.8 766f2946af chore: add workshop-llm LiteLLM proxy deploy + ignore vendored/generated files
Commits the workshop inference pool (LiteLLM → boards: pooled coding plans,
per-attendee virtual keys, failover) — config + docs only, no secrets. Ignores
the vendored Uno-QClaw reference repo and the generated qr-sheet.html.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-07-16 11:42:05 -07:00

34 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Mint N temporary per-attendee virtual keys on the LiteLLM proxy.
#
# Each key gets: access to the `workshop` model ONLY (never instructor-claude),
# a spend cap, a per-key rate limit, and an expiry. Prints CSV: alias,key.
#
# LITELLM_MASTER_KEY=sk-master-… ./gen-attendee-keys.sh 30 > attendee-keys.csv
#
# Env: PROXY (default http://localhost:4000), BUDGET usd, RPM, DUR.
set -euo pipefail
PROXY="${PROXY:-http://localhost:4000}"
MASTER="${LITELLM_MASTER_KEY:?set LITELLM_MASTER_KEY}"
N="${1:-30}"
BUDGET="${BUDGET:-3.0}" # USD/attendee — covers metered Groq/Gemini overflow
RPM="${RPM:-12}" # per-attendee requests/min
DUR="${DUR:-24h}" # temporary keys expire after the event
mint() { # alias, models-json -> key
curl -sf -X POST "$PROXY/key/generate" \
-H "Authorization: Bearer $MASTER" -H "Content-Type: application/json" \
-d "{\"models\":$2,\"max_budget\":$BUDGET,\"rpm_limit\":$RPM,\"key_alias\":\"$1\",\"duration\":\"$DUR\"}" \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["key"])'
}
echo "alias,key"
for i in $(seq 1 "$N"); do
alias=$(printf "attendee-%02d" "$i")
echo "$alias,$(mint "$alias" '["workshop"]')"
done
# Instructor key (adds Claude access + bigger budget) — run once, separately:
# mint instructor '["workshop","instructor-claude"]' # with BUDGET=50 DUR=720h