Break down what the workspace is spending (`modal billing`). Costs are fetched once
and aggregated locally, so you get ranked totals and period-over-period changes
rather than hundreds of raw rows.
Answering common questions:
"what is my costliest app?" -> view="by_app", period="this month"
"why was Monday expensive?" -> view="timeline", period="last week" (the
`explanation` field diffs the peak day against
the day before and ranks which apps grew)
"what did that day cost hourly?" -> view="timeline", start="2026-08-31",
end="2026-09-01", resolution="h"
"where does the money go?" -> view="by_resource" (CPU / GPU / memory / ...)
"what is the bill this cycle?" -> view="summary"
Billing is workspace-wide, so this reports across every environment; use
`environment` to narrow it after the fact.
Args:
view: "by_app" (default), "timeline" (per interval, with an explanation of the
peak), "by_environment", "by_resource", "summary" (billed vs metered for a
month cycle), or "rates" (current unit prices).
period: Convenience range — "today", "yesterday", "this week", "last week",
"this month", "last month". For "summary" also accepts "YYYY-MM".
start / end: Explicit range instead of `period` — ISO dates ("2026-08-31") or
relative ("3 days ago"). Start is inclusive, end exclusive; end defaults to now.
resolution: "d" (daily, default) or "h" (hourly). Hourly is what you want when
drilling into a single day.
timezone: Timezone for interpreting dates — "local", an offset ("+05:30"), or an
IANA name. Requires resolution="h".
app: Only include apps whose name or ID contains this string (case-insensitive).
environment: Only include rows from this Modal environment.
top_n: How many groups/movers to return. Default 10.
tag_names: Comma-separated cost-attribution tag names to include.
Returns: {total_cost, groups | intervals, explanation (for timeline), row_count}.
Costs are strings of US dollars with 4 decimals. `total_cost` always covers every
row in range, even when `groups` is cut to top_n.