import { Billing } from "@opencode/cloud-core/billing.js" import { query, useParams, createAsync } from "@solidjs/router" import { createMemo, For, Show } from "solid-js" import { formatDateUTC, formatDateForTable } from "./common" import { withActor } from "~/context/auth.withActor" import styles from "./usage-section.module.css" const getUsageInfo = query(async (workspaceID: string) => { "use server" return withActor(async () => { return await Billing.usages() }, workspaceID) }, "usage.list") export function UsageSection() { const params = useParams() const usage = createAsync(() => getUsageInfo(params.id)) return (

Usage History

Recent API usage and costs.

0} fallback={

Make your first API call to get started.

} > {(usage) => { const date = createMemo(() => new Date(usage.timeCreated)) return ( ) }}
Date Model Input Output Cost
{formatDateForTable(date())} {usage.model} {usage.inputTokens} {usage.outputTokens} ${((usage.cost ?? 0) / 100000000).toFixed(4)}
) }