spb/zyquo-cloud-web Public MIT
Zyquo Cloud Web — every cloud model, one beautiful chat, entirely in your browser.
TypeScript 81.9%
CSS 8.9%
JavaScript 7.5%
Shell 1.1%
HTML 0.6%
1/*2 * catalogHelpers.ts3 * Zyquo Cloud Web4 *5 * Author: Simon-Pierre Boucher6 * Mail: contact@spboucher.ai7 *8 * Catalog conveniences shared by the store and UI: re-exports of the ported9 * catalog queries plus cost/estimation helpers.10 */1112import { pricingCost, type AIModel, type TokenUsage } from '../types'1314export { CATALOG, cheapestModel, defaultModel, findModel, modelsFor, rankModel } from '../providers/catalog'1516/** Estimated USD cost of a usage record for a model (0 when unpriced). */17export function pricedCost(model: AIModel, usage: TokenUsage): number {18 if (!model.pricing) return 019 return pricingCost(model.pricing, usage.inputTokens, usage.outputTokens)20}2122/** Rough token estimate for context-window accounting (≈4 chars/token). */23export function estimateTokens(text: string): number {24 return Math.ceil(text.length / 4)25}2627/** "$1.25 / $10" per-MTok badge, or "—" when unpriced. */28export function priceBadge(model: AIModel): string {29 if (!model.pricing) return '—'30 const fmt = (v: number) => (v >= 1 ? `$${v.toFixed(2).replace(/\.?0+$/, '')}` : `$${v}`)31 return `${fmt(model.pricing.inputPerMTok)} / ${fmt(model.pricing.outputPerMTok)}`32}3334/** "$0.0042" style cost display. */35export function costLabel(cost: number): string {36 if (cost <= 0) return ''37 return `~$${cost.toFixed(4)}`38}39