mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-29 07:20:43 +00:00
The root layout handed every page the plan catalog (lib/rooms.ts configure with lib/data/plans.json), and /pricing, /calculator, /customers and the benchmark pages bundled the 202 KB price list. lib/api is now the one reader: plans() GET /v1/billing/plans, pricing() /v1/pricing, summary(), served() /v1/models, templates(), blueprints() /v1/blueprint/sbom, one promise a path a page load, each drawn as loading, ready or "api.hanzo.ai is unreachable" (components/api) and never an older number. plans.json, pricing.json, models.json, templates.json, blueprints.json and sync-pricing, sync-models, sync-templates, sync-blueprints are gone. What a static export must know before anyone asks, which model pages exist and their titles, is read by the build itself (lib/api/build, Next's fetch cache keyed by the build's stamp: one answer per build) and renders no rate. lib/moved reads the retired model pages against the export, and the 153 pages the old snapshot kept for models the gateway dropped are in retired.json. Kai's price beside Jev's, Enso's tier rates, a model page's rate and the GPU table read the price list in the browser; the site's plan math no longer imports @hanzo/rooms/lib/plans, whose bundled @hanzo/plans catalog rode the home, /pricing and the picker. Home first load 452.7 -> 437.4 KB gzip (budget 440); pages over perf.budget.json 32 -> 9, the rest over for settings code, connectors and the commerce catalog. The gates serve invented answers (e2e/gates/api) and block them; e2e/gates/read.spec.ts holds that no script carries a plan, price or model table.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
'use client'
|
|
|
|
/**
|
|
* A model's rate where a page states one in passing — a tier card, a figure, a
|
|
* sentence — read from the price list (GET /v1/pricing, lib/api) when the page
|
|
* opens. The export carries an ellipsis in its place, never a number; a rate
|
|
* the backend does not answer for reads as a dash.
|
|
*/
|
|
|
|
import { usePricing } from '@/lib/api/use'
|
|
import { rate, type Price as Rate } from '@/lib/api/read'
|
|
import { dollars } from '@/lib/tally'
|
|
import { Inline } from './state'
|
|
|
|
/** One side of a model's per-million-token rate: `$4`, `$0.021`. */
|
|
export function Price({ id, side }: { id: string; side: keyof Pick<Rate, 'input' | 'output'> }) {
|
|
return <Inline reading={usePricing()}>{(doc) => money(rate(doc, id)?.[side])}</Inline>
|
|
}
|
|
|
|
/** Both sides, input then output: `$4 → $20`. */
|
|
export function Pair({ id }: { id: string }) {
|
|
return (
|
|
<Inline reading={usePricing()}>
|
|
{(doc) => {
|
|
const r = rate(doc, id)
|
|
return `${money(r?.input)} → ${money(r?.output)}`
|
|
}}
|
|
</Inline>
|
|
)
|
|
}
|
|
|
|
/** What a thousand tokens in and a thousand out cost: `$0.024`. */
|
|
export function Call({ id }: { id: string }) {
|
|
return (
|
|
<Inline reading={usePricing()}>
|
|
{(doc) => {
|
|
const r = rate(doc, id)
|
|
return r?.input == null || r.output == null ? '—' : `$${(0.001 * (r.input + r.output)).toFixed(3)}`
|
|
}}
|
|
</Inline>
|
|
)
|
|
}
|
|
|
|
const money = (n: number | null | undefined) => (n == null ? '—' : dollars(n))
|