Sonnet 5.5 as the default AI model, and a model list with prices (1.6.1)

Settings -> AI picks the model from a list (utils/aiModels.js: Sonnet,
Haiku, Opus 5.5 with list prices) or takes another model ID; choosing
one fills in its prices. Blank prices use the built-in ones, and cache
reads are metered at each model's own price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 17:21:30 +02:00
co-authored by Claude Opus 5.5
parent 160ff3b927
commit ae7e10844d
12 changed files with 131 additions and 26 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "events-hub-frontend",
"version": "1.6.0",
"version": "1.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "events-hub-frontend",
"version": "1.6.0",
"version": "1.6.1",
"dependencies": {
"lucide-react": "^0.536.0",
"next": "^15.5.24",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "events-hub-frontend",
"version": "1.6.0",
"version": "1.6.1",
"private": true,
"scripts": {
"dev": "next dev -p 3200",
+45 -8
View File
@@ -32,17 +32,29 @@ const TABS: { key: Tab; label: string }[] = [
type AiUsage = { month: string; installs: AiInstallUse[]; totals: { calls: number; realCents: number; chargedCents: number; profitCents: number } };
type AiModel = { id: string; label: string; inputUsd: number; outputUsd: number; cacheReadUsd: number; note: string };
const AI_KEYS = ["ai_model", "ai_input_usd_per_mtok", "ai_output_usd_per_mtok", "ai_usd_zar", "ai_markup_percent"];
const OTHER = "__other";
const AI_FIELDS: { key: string; label: string; hint: string; type?: string }[] = [
{ key: "ai_model", label: "Model", hint: "claude-haiku-5-5 — the cheapest current model." },
{ key: "ai_input_usd_per_mtok", label: "Input price (US$ per million tokens)", hint: "Haiku 5.5: 0.10 (prompts under 100K tokens).", type: "number" },
{ key: "ai_output_usd_per_mtok", label: "Output price (US$ per million tokens)", hint: "Haiku 5.5: 0.50.", type: "number" },
{ key: "ai_usd_zar", label: "Exchange rate (rand per US$)", hint: "AI stays off until this is set. Each call is charged at the rate in force when it ran.", type: "number" },
{ key: "ai_markup_percent", label: "Default markup (%)", hint: "Added to the real cost; covers small overruns and is the profit. A licence can override it.", type: "number" },
];
/** Settings → AI: the Claude key and prices, and what each install used this month. */
function AiTab({ settings, onSaved, setMsg }: { settings: Settings; onSaved: (s: Settings) => void; setMsg: (m: Msg) => void }) {
const [form, setForm] = useState(() => Object.fromEntries(AI_FIELDS.map(f => [f.key, settings[f.key] ?? ""])));
/** Settings → AI: the Claude key, model and prices, and what each install used this month. */
function AiTab({ settings, models, onSaved, setMsg }: { settings: Settings; models: AiModel[]; onSaved: (s: Settings) => void; setMsg: (m: Msg) => void }) {
const [form, setForm] = useState(() => Object.fromEntries(AI_KEYS.map(k => [k, settings[k] ?? ""])));
const known = models.find(m => m.id === form.ai_model);
const [other, setOther] = useState(() => !!form.ai_model && !known);
// Choosing a model fills in its list prices; they stay editable.
const chooseModel = (value: string) => {
if (value === OTHER) { setOther(true); setForm({ ...form, ai_model: "" }); return; }
const m = models.find(x => x.id === value);
setOther(false);
setForm({ ...form, ai_model: value, ...(m ? { ai_input_usd_per_mtok: String(m.inputUsd), ai_output_usd_per_mtok: String(m.outputUsd) } : {}) });
};
const pricesDiffer = !!known && (parseFloat(form.ai_input_usd_per_mtok) !== known.inputUsd || parseFloat(form.ai_output_usd_per_mtok) !== known.outputUsd);
const [key, setKey] = useState({ value: "", clear: false });
const [testing, setTesting] = useState(false);
const [month, setMonth] = useState("");
@@ -85,6 +97,30 @@ function AiTab({ settings, onSaved, setMsg }: { settings: Settings; onSaved: (s:
)}
<p className="mt-1 text-xs text-slate-500">Stored encrypted; never sent to the browser or to sites.</p>
</div>
<div>
<label className="label" htmlFor="ai_model">Model</label>
<select id="ai_model" className="input" value={other ? OTHER : form.ai_model} onChange={e => chooseModel(e.target.value)}>
{models.map(m => <option key={m.id} value={m.id}>{m.label} — ${m.inputUsd} / ${m.outputUsd} per million tokens</option>)}
<option value={OTHER}>Another model (type its ID)</option>
</select>
{other ? (
<input id="ai_model_other" aria-label="Model ID" className="input mt-2" placeholder="claude-…" value={form.ai_model} onChange={e => setForm({ ...form, ai_model: e.target.value })} />
) : known && <p className="mt-1 text-xs text-slate-500">{known.note}</p>}
</div>
<div className="grid gap-3 sm:grid-cols-2">
<div>
<label className="label" htmlFor="ai_input_usd_per_mtok">Input price (US$ per million tokens)</label>
<input id="ai_input_usd_per_mtok" className="input" type="number" step="any" min={0} value={form.ai_input_usd_per_mtok} onChange={e => setForm({ ...form, ai_input_usd_per_mtok: e.target.value })} />
</div>
<div>
<label className="label" htmlFor="ai_output_usd_per_mtok">Output price (US$ per million tokens)</label>
<input id="ai_output_usd_per_mtok" className="input" type="number" step="any" min={0} value={form.ai_output_usd_per_mtok} onChange={e => setForm({ ...form, ai_output_usd_per_mtok: e.target.value })} />
</div>
</div>
<p className="-mt-1 text-xs text-slate-500">
{other ? "Enter the model's prices from Anthropic's pricing page." : "Filled in from Anthropic's list prices when you choose a model. Change them only if Anthropic's prices change."}
{pricesDiffer && <> These differ from the list price (${known!.inputUsd} / ${known!.outputUsd}). <button type="button" className="text-indigo-700 hover:underline" onClick={() => chooseModel(known!.id)}>Use the list price</button></>}
</p>
{AI_FIELDS.map(f => (
<div key={f.key}>
<label className="label" htmlFor={f.key}>{f.label}</label>
@@ -133,6 +169,7 @@ export default function SettingsPage() {
const [settings, setSettings] = useState<Settings | null>(null);
const [publicKey, setPublicKey] = useState("");
const [smtp, setSmtp] = useState(false);
const [aiModels, setAiModels] = useState<AiModel[]>([]);
const [audit, setAudit] = useState<AuditRow[]>([]);
const [auditQuery, setAuditQuery] = useState("");
const [pw, setPw] = useState({ currentPassword: "", newPassword: "" });
@@ -142,7 +179,7 @@ export default function SettingsPage() {
const [testing, setTesting] = useState(false);
useEffect(() => {
api<{ settings: Settings; publicKey: string; smtp: boolean }>("/api/admin/settings").then(r => { setSettings(r.settings); setPublicKey(r.publicKey); setSmtp(r.smtp); }).catch(e => setMsg({ type: "err", text: errorText(e) }));
api<{ settings: Settings; publicKey: string; smtp: boolean; aiModels: AiModel[] }>("/api/admin/settings").then(r => { setSettings(r.settings); setPublicKey(r.publicKey); setSmtp(r.smtp); setAiModels(r.aiModels || []); }).catch(e => setMsg({ type: "err", text: errorText(e) }));
api<AuditRow[]>("/api/admin/audit").then(setAudit).catch(() => {});
// Open the tab named in the address (#email), so a reload or a link lands in the same place.
const fromHash = window.location.hash.slice(1);
@@ -264,7 +301,7 @@ export default function SettingsPage() {
</form>
)}
{tab === "ai" && <AiTab settings={settings} onSaved={setSettings} setMsg={setMsg} />}
{tab === "ai" && <AiTab settings={settings} models={aiModels} onSaved={setSettings} setMsg={setMsg} />}
{tab === "security" && (
<div className="max-w-2xl space-y-6">