import "./index.css" import { Link, Meta, Title } from "@solidjs/meta" import { ProviderIcon } from "@opencode-ai/ui/provider-icon" import ibmPlexMonoRegularLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-Regular-Latin1.woff2?url" import ibmPlexMonoMediumLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-Medium-Latin1.woff2?url" import ibmPlexMonoSemiBoldLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-SemiBold-Latin1.woff2?url" import ibmPlexMonoBoldLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-Bold-Latin1.woff2?url" import opencodeWordmarkDark from "../asset/logo-ornate-dark.svg" import { getStatsHomeData, type LeaderboardEntry, type MarketDay, type StatsHomeData, type SessionCostEntry, type TokenCostEntry, type UsagePoint, } from "@opencode-ai/stats-core/domain/home" import { runtime } from "@opencode-ai/stats-core/runtime" import { createAsync, query } from "@solidjs/router" import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show, type JSX } from "solid-js" import { getRequestEvent } from "solid-js/web" const products = ["All Users", "Zen", "Go"] as const const tokenProducts = ["Zen", "Go"] as const const ranges = ["1D", "1W", "2W", "1M", "2M"] as const const rangeLabels: Record = { "1D": "1 Day", "1W": "1 Week", "2W": "2 Weeks", "1M": "1 Month", "2M": "2 Months", } const headerLinks = [ { href: "#top-models", label: "Top Models" }, { href: "#leaderboard", label: "Leaderboard" }, { href: "#market-share", label: "Market Share" }, { href: "#token-cost", label: "Token Cost" }, { href: "#session-cost", label: "Session Cost" }, ] as const const usageColors = [ "#ed6aff", "#a684ff", "#7c86ff", "#51a2ff", "#00d3f2", "#00d5be", "#00bc7d", "#9ae600", "#ffb900", "#ff8904", "#ff6467", ] const marketColors = ["#ed6aff", "#a684ff", "#7c86ff", "#51a2ff", "#00d3f2", "#00d5be", "#00bc7d", "#9ae600", "#ffb900"] type UsageProduct = (typeof products)[number] type TokenProduct = (typeof tokenProducts)[number] type UsageRange = (typeof ranges)[number] const getData = query(async () => { "use server" return runtime.runPromise(getStatsHomeData()) }, "getStatsHomeData") export default function StatsHome() { getRequestEvent()?.response.headers.set( "Cache-Control", "public, max-age=60, s-maxage=300, stale-while-revalidate=86400", ) const data = createAsync(() => getData()) return (
OpenCode Stats
}> {(stats) => ( <> )}
) } function Hero(props: { updatedAt: string | null }) { const [timeZone, setTimeZone] = createSignal("UTC") const [previousTimeZone, setPreviousTimeZone] = createSignal("UTC") const [isTicking, setIsTicking] = createSignal(false) const updatedAtParts = (timeZone: string) => props.updatedAt ? formatUpdatedAtParts(props.updatedAt, timeZone) : { date: "No rows yet", time: "" } const previousUpdatedAt = createMemo(() => updatedAtParts(previousTimeZone())) const currentUpdatedAt = createMemo(() => updatedAtParts(timeZone())) const currentUpdatedLabel = createMemo(() => props.updatedAt ? `Updated ${formatUpdatedAtLabel(currentUpdatedAt())}` : "No rows yet", ) const isDateTicking = createMemo(() => isTicking() && previousUpdatedAt().date !== currentUpdatedAt().date) const isTimeTicking = createMemo(() => isTicking() && previousUpdatedAt().time !== currentUpdatedAt().time) onMount(() => { if (!props.updatedAt) return const nextTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC" if (nextTimeZone === "UTC") return if ( formatUpdatedAtLabel(formatUpdatedAtParts(props.updatedAt, nextTimeZone)) === formatUpdatedAtLabel(updatedAtParts("UTC")) ) return const timeouts: number[] = [] timeouts.push( window.setTimeout(() => { setPreviousTimeZone(timeZone()) setTimeZone(nextTimeZone) setIsTicking(true) timeouts.push( window.setTimeout(() => { setPreviousTimeZone(nextTimeZone) setIsTicking(false) }, 720), ) }, 480), ) onCleanup(() => timeouts.forEach((timeout) => window.clearTimeout(timeout))) }) return (

{props.updatedAt ? ( <> ) : ( No rows yet )}

) } function HeroMetaTickerPart(props: { previous: string; current: string; ticking: boolean }) { return ( {props.previous} {props.current} ) } function StatsLoading() { return ( <> ) } function ChartSection(props: { id?: string title: string description?: string controls?: JSX.Element children: JSX.Element }) { return (

{props.title}

{props.description &&

{props.description}

}
{props.controls}
{props.children}
) } function SectionTitle(props: { title: string; description: string }) { return (

{props.title}. {props.description}

) } function SectionBridge(props: { label: string; href: string }) { return ( LEAN MORE {props.label} ) } function EmptyState(props: { title: string; description: string }) { return (
{props.title}

{props.description}

) } function formatUpdatedAtParts(value: string, timeZone: string) { const date = new Date(value) if (Number.isNaN(date.getTime())) return { date: "just now", time: "" } return { date: new Intl.DateTimeFormat("en", { month: "short", day: "numeric", timeZone, }).format(date), time: new Intl.DateTimeFormat("en", { hour: "numeric", minute: "2-digit", timeZone, timeZoneName: "short", }).format(date), } } function formatUpdatedAtLabel(value: { date: string; time: string }) { if (!value.time) return value.date return `${value.date}, ${value.time}` } function TopModelsSection(props: { data: StatsHomeData["usage"] }) { const [product, setProduct] = createSignal("All Users") const [range, setRange] = createSignal("1W") const [sheet, setSheet] = createSignal<"product" | "range">() const data = createMemo(() => props.data[product()][range()]) createEffect(() => { if (!sheet()) return if (typeof document === "undefined") return const htmlOverflow = document.documentElement.style.overflow const bodyOverflow = document.body.style.overflow document.documentElement.style.overflow = "hidden" document.body.style.overflow = "hidden" const onKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") setSheet(undefined) } document.addEventListener("keydown", onKeyDown) onCleanup(() => { document.documentElement.style.overflow = htmlOverflow document.body.style.overflow = bodyOverflow document.removeEventListener("keydown", onKeyDown) }) }) return (

Top models. Usage of models across OpenCode.

setSheet(sheet() === "product" ? undefined : "product")} /> setSheet(sheet() === "range" ? undefined : "range")} />
usageTotal(item) > 0)} fallback={} >
{(kind) => ( { setProduct(value) setSheet(undefined) }} onRangeSelect={(value) => { setRange(value) setSheet(undefined) }} onClose={() => setSheet(undefined)} /> )}
) } function MobileFilterButton(props: { label: string; value: string; expanded: boolean; onClick: () => void }) { return ( ) } function MobileFilterSheet(props: { kind: "product" | "range" product: UsageProduct range: UsageRange onProductSelect: (product: UsageProduct) => void onRangeSelect: (range: UsageRange) => void onClose: () => void }) { return (
{(item) => ( )} } > {(item) => ( )}
) } function ChevronDown() { return ( ) } function StatsFilters(props: { product: UsageProduct range: UsageRange onProductSelect: (product: UsageProduct) => void onRangeSelect: (range: UsageRange) => void }) { return ( <> ) } function FilterPills(props: { items: readonly T[] selected: T label: string variant: "product" | "range" onSelect: (item: T) => void }) { return (
{(item) => ( )}
) } function TopModelsChart(props: { data: UsagePoint[]; range: UsageRange }) { const [activeIndex, setActiveIndex] = createSignal() const [activeSegment, setActiveSegment] = createSignal() const maxTotal = createMemo(() => getTopModelsMaxTotal(props.data)) const activePoint = createMemo(() => props.data[activeIndex() ?? -1]) return (
{(day, dayIndex) => (
{ if (event.pointerType !== "touch") return setActiveIndex(dayIndex()) setActiveSegment(undefined) }} onPointerEnter={() => { setActiveIndex(dayIndex()) setActiveSegment(undefined) }} onPointerLeave={(event) => { if (event.pointerType === "touch") return setActiveIndex(undefined) setActiveSegment(undefined) }} onClick={() => setActiveIndex(dayIndex())} onFocus={() => { setActiveIndex(dayIndex()) setActiveSegment(undefined) }} onBlur={() => { setActiveIndex(undefined) setActiveSegment(undefined) }} onKeyDown={(event) => { if (event.key !== "Enter" && event.key !== " ") return event.preventDefault() setActiveIndex(dayIndex()) setActiveSegment(undefined) }} >
{(item) => ( { event.stopPropagation() setActiveIndex(dayIndex()) setActiveSegment(item.index) }} onPointerDown={(event) => { event.stopPropagation() setActiveIndex(dayIndex()) setActiveSegment(item.index) }} onClick={(event) => { event.stopPropagation() setActiveIndex(dayIndex()) setActiveSegment(item.index) }} /> )}
{(point) => (
props.data.length * 0.62 ? "left" : "right"} > {point().date} {formatTokens(usageTotal(point()))} total
{(item) => (

{item.segment.model} {formatTokens(item.segment.value)}

)}
)}
)}
) } function getTopModelsBarHeight(total: number, max: number) { if (total <= 0) return 0 return Math.max(2, Math.min(100, (total / max) * 100)) } function getTopModelsMaxTotal(data: UsagePoint[]) { const max = Math.max(0, ...data.map((item) => usageTotal(item))) if (max === 0) return 1 if (data.length === 1) return max * 1.75 return max } function getTopModelsSegmentRows(point: UsagePoint) { const total = usageTotal(point) if (total <= 0) return "" return visibleTopModelsSegments(point) .map((item) => `${(item.segment.value / total) * 100}%`) .join(" ") } function visibleTopModelsSegments(point: UsagePoint) { return point.segments.map((segment, index) => ({ segment, index })).filter((item) => item.segment.value > 0) } function getTopModelsSegmentColor(index: number, muted: boolean, activeSegment: number | undefined) { if (activeSegment !== undefined) return activeSegment === index ? (usageColors[index] ?? "var(--stats-text)") : "var(--stats-layer-2)" if (muted) return "var(--stats-layer-2)" return usageColors[index] ?? "var(--stats-text)" } function isTopModelsMobileAxisHidden(index: number, count: number) { return count > 7 && index % 2 === 1 } function formatTopModelsMobileDate(label: string, range: UsageRange) { if (range === "1M" || range === "2M") return label.split(" - ")[0] ?? label return label } function usageTotal(point: UsagePoint) { return point.segments.reduce((sum, item) => sum + item.value, 0) } function formatTokens(value: number) { if (value >= 1) return `${value.toFixed(value >= 10 ? 0 : 1)}T` return `${Math.round(value * 1000)}B` } function LeaderboardSection(props: { data: StatsHomeData["leaderboard"] }) { const [product, setProduct] = createSignal("All Users") const [range, setRange] = createSignal("1W") const data = createMemo(() => props.data[product()][range()]) return (
0} fallback={ } >
) } function Leaderboard(props: { data: LeaderboardEntry[] }) { const featured = createMemo(() => props.data.slice(0, 3)) const columns = createMemo(() => [0, 1, 2].map((index) => props.data.slice(3 + index * 5, 8 + index * 5)).filter((column) => column.length > 0), ) return (
{(entry) => }
) } function LeaderboardCard(props: { entry: LeaderboardEntry; size: "featured" | "compact" }) { return (
{String(props.entry.rank).padStart(2, "0")}
) } function getProviderIconId(author: string) { if (author === "MiniMax") return "minimax" if (author === "Moonshot") return "moonshotai" if (author === "Zhipu") return "zhipuai" return author.toLowerCase() } function formatBillions(value: number) { if (value >= 1000) return `${(value / 1000).toFixed(value >= 10000 ? 0 : 1)}T` return `${value}B` } function formatChange(value: number) { if (value > 0) return `+${value}%` return `${value}%` } function MarketShareSection(props: { data: StatsHomeData["market"] }) { const [range, setRange] = createSignal("1W") const [activeIndex, setActiveIndex] = createSignal(2) const [activeAuthor, setActiveAuthor] = createSignal() const [inspecting, setInspecting] = createSignal(false) const data = createMemo(() => props.data[range()]) const selectedIndex = createMemo(() => Math.min(activeIndex(), Math.max(data().length - 1, 0))) const activeDay = createMemo(() => data()[selectedIndex()]) return (
{ if (event.pointerType === "touch") return setActiveAuthor(undefined) setInspecting(false) }} > } > {(day) => ( <> { setActiveIndex(index) setInspecting(true) }} onActiveAuthorChange={(author) => { setActiveAuthor(author) setInspecting(true) }} /> { setActiveAuthor(author) setInspecting(true) }} /> )}

[*] {inspecting() ? formatMarketDate(activeDay()) : formatMarketRange(data())}

{ setRange(item) setActiveAuthor(undefined) setInspecting(false) }} />
) } function MarketShare(props: { data: MarketDay[] activeIndex: number activeAuthor: string | undefined inspecting: boolean onActiveIndexChange: (index: number) => void onActiveAuthorChange: (author: string) => void }) { return (
{(day, index) => ( )}
{(day, index) => ( )}
) } function MarketShareList(props: { data: MarketDay["authors"] activeAuthor: string | undefined onActiveAuthorChange: (author: string) => void }) { return (
    {(item, index) => (
  1. props.onActiveAuthorChange(item.author)} onFocus={() => props.onActiveAuthorChange(item.author)} onKeyDown={(event) => { if (event.key !== "Enter" && event.key !== " ") return event.preventDefault() props.onActiveAuthorChange(item.author) }} > {String(index() + 1).padStart(2, "0")} {item.author} {formatTrillions(item.tokens)} {item.share.toFixed(1)}%
  2. )}
) } function getMarketSegmentColor(author: string, color: string, activeAuthor: string | undefined) { if (!activeAuthor) return color if (activeAuthor === author) return color return "var(--stats-bar-idle)" } function formatTrillions(value: number) { return `${value.toFixed(value >= 10 ? 0 : 1)}T` } function formatMarketDate(day: MarketDay | undefined) { if (!day) return "No data" return `${day.date} ${new Date().getFullYear()}` } function formatMarketRange(data: MarketDay[]) { const first = data[0]?.date const last = data[data.length - 1]?.date if (!first || !last) return "No data" const year = new Date().getFullYear() return `${first} ${year} → ${last} ${year}` } function TokenCostSection(props: { data: StatsHomeData["tokenCost"] }) { const [product, setProduct] = createSignal("Zen") const [activeIndex, setActiveIndex] = createSignal(2) const data = createMemo(() => props.data[product()]) const visible = createMemo(() => data().slice(0, 13)) const selectedIndex = createMemo(() => Math.min(activeIndex(), Math.max(visible().length - 1, 0))) return (
0} fallback={ } >
) } function TokenCostChart(props: { data: TokenCostEntry[] activeIndex: number onActiveIndexChange: (index: number) => void }) { const max = createMemo(() => Math.max(1, ...props.data.map((item) => item.total))) const active = createMemo(() => props.data[props.activeIndex] ?? props.data[0]) return (
{(item, index) => ( )} {(item) => (

Input {formatDollars(item().input)}

Output {formatDollars(item().output)}

Cached {formatDollars(item().cached)}

)}
) } function formatDollars(value: number) { return `$${value.toFixed(2)}` } function MetricBar(props: { value: number; max: number; active: boolean }) { return ( ) } function SessionCostSection(props: { data: StatsHomeData["sessionCost"] }) { const [product, setProduct] = createSignal("Zen") const [activeIndex, setActiveIndex] = createSignal(2) const data = createMemo(() => props.data[product()]) const visible = createMemo(() => data().slice(0, 16)) const selectedIndex = createMemo(() => Math.min(activeIndex(), Math.max(visible().length - 1, 0))) return (
0} fallback={ } >
) } function SessionCostChart(props: { data: SessionCostEntry[] activeIndex: number onActiveIndexChange: (index: number) => void }) { const maxCost = createMemo(() => Math.max(1, ...props.data.map((item) => item.cost))) const maxTokens = createMemo(() => Math.max(1, ...props.data.map((item) => item.tokens))) const active = createMemo(() => props.data[props.activeIndex] ?? props.data[0]) return (

COST / SESSION

TOKENS / SESSIONS

{(item, index) => ( )} {(item) => (

Cost/Session {formatSessionCost(item().cost)}

Tokens/Session {formatTokenCount(item().tokens)}

)}
) } function LiveIndicator() { return Live } function formatTokenCount(value: number) { if (value >= 1_000_000) return `${Number((value / 1_000_000).toFixed(1))}M` return `${Math.round(value / 1_000)}K` } function formatSessionCost(value: number) { return `$${value.toFixed(4)}` } function Header() { const [menuOpen, setMenuOpen] = createSignal(false) const [menuViewport, setMenuViewport] = createSignal(false) createEffect(() => { if (typeof window === "undefined") return const media = window.matchMedia("(max-width: 74.999rem)") const update = () => setMenuViewport(media.matches) update() media.addEventListener("change", update) onCleanup(() => media.removeEventListener("change", update)) }) createEffect(() => { if (!menuOpen()) return if (!menuViewport()) return if (typeof document === "undefined") return const page = document.querySelector('[data-page="stats"]') const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth const htmlOverflow = document.documentElement.style.overflow const pagePaddingRight = page?.style.paddingRight const bodyOverflow = document.body.style.overflow document.documentElement.style.overflow = "hidden" if (scrollbarWidth > 0 && page) page.style.paddingRight = `${scrollbarWidth}px` document.body.style.overflow = "hidden" onCleanup(() => { document.documentElement.style.overflow = htmlOverflow if (page && pagePaddingRight !== undefined) page.style.paddingRight = pagePaddingRight document.body.style.overflow = bodyOverflow }) }) return (
GitHub [150K] Try OpenCode
) } function StatsWordmark() { return ( ) } function StatsMark() { return ( ) } function OpenCodeMark() { return ( ) } function Footer() { const [subscribeOpen, setSubscribeOpen] = createSignal(false) const modelStats = [ { href: "#top-models", label: "Top Models" }, { href: "#leaderboard", label: "Leaderboard" }, { href: "#market-share", label: "Market Share" }, { href: "#token-cost", label: "Token Cost" }, { href: "#session-cost", label: "Session Cost" }, ] const legal = [ { href: "https://opencode.ai/legal/terms-of-service", label: "Terms of service" }, { href: "https://opencode.ai/legal/privacy-policy", label: "Privacy policy" }, ] const connect = [ { href: "mailto:hello@opencode.ai", label: "Contact us" }, { href: "https://opencode.ai/discord", label: "Community" }, { href: "https://x.com/opencode", label: "X" }, { href: "https://github.com/anomalyco/opencode", label: "GitHub" }, { href: "https://www.youtube.com/@anomaly-co", label: "YouTube" }, ] return (

Newsletter

Be the first to know about new releases.

) } function SubscribeModal(props: { onClose: () => void }) { const [status, setStatus] = createSignal<"idle" | "pending" | "success" | "error">("idle") const [message, setMessage] = createSignal("") let input: HTMLInputElement | undefined onMount(() => { if (typeof document === "undefined") return const activeElement = document.activeElement instanceof HTMLElement ? document.activeElement : undefined const htmlOverflow = document.documentElement.style.overflow const bodyOverflow = document.body.style.overflow document.documentElement.style.overflow = "hidden" document.body.style.overflow = "hidden" const focusTimeout = window.setTimeout(() => input?.focus(), 0) const onKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") props.onClose() } document.addEventListener("keydown", onKeyDown) onCleanup(() => { window.clearTimeout(focusTimeout) document.documentElement.style.overflow = htmlOverflow document.body.style.overflow = bodyOverflow document.removeEventListener("keydown", onKeyDown) activeElement?.focus() }) }) return (
) } function newsletterErrorMessage(response: Response) { return response.json().then( (body: unknown) => body && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : "Failed to subscribe", () => "Failed to subscribe", ) } function FooterColumn(props: { title: string; links: { href: string; label: string }[] }) { return (

{props.title}

) }