#!/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