{% extends 'base.html' %} {% block title %}Usage & cost - Memorizz{% endblock %} {% block head %}{% endblock %} {% block content %} {% from '_ui.html' import page_header, observability_tabs, empty_state %} {% from '_fmt.html' import count, usd, usd_exact, percent %} {% from '_run_health.html' import range_picker with context %} {% from '_analytics_charts.html' import donut, bars %} {% set window_labels = {'24h': 'Last 24 hours', '7d': 'Last 7 days', '30d': 'Last 30 days', '90d': 'Last 90 days', 'all': 'All recorded usage'} %} {% set window_label = window_labels.get(window) or fmt_range(span) %} {% set series = view.series %} {% set totals = usage.totals %} {% macro delta(entry) -%} {%- if entry.delta is not none -%} {{ '▲' if entry.delta > 0 else ('▼' if entry.delta < 0 else '') }} {{ '%.0f'|format(entry.delta|abs) }}% {%- elif view.compared and entry.kind != 'percent' -%} new {%- endif -%} {%- endmacro %} {% macro figure(entry) -%} {%- if entry.kind == 'usd' -%}{{ usd(entry.value, '—') }} {%- elif entry.kind == 'duration' -%}{{ fmt_duration(entry.value) }} {%- elif entry.kind == 'percent' -%}{{ percent(entry.value, 'Not reported') if entry.value is not none else '—' }} {%- else -%}{{ fmt_compact(entry.value) }} {%- endif -%} {%- endmacro %} {% call page_header('Usage & cost', 'Spend, tokens and model calls by agent, model and run, compared with the period before.', 'Operations', nav=observability_tabs('usage', {'traces': trace_url})) %} {{ range_picker('/traces/usage', window, windows, span, query, {'all': 'All'}) }}
Export
Rate cards {% endcall %}
{% for key, value in preserved_filters.items() %}{% endfor %} {% for key, value in ranged.items() %}{% endfor %} {% if metric != 'tokens' %}{% endif %}
More
{% if query.agent_id or query.model %}Clear filters{% endif %}

{{ window_label }} {% if view.compared %}Compared with the {{ 'same length of time' if window == 'custom' else window_label|lower|replace('last ', '') }} before{% elif view.previous_empty %}Nothing recorded in the {{ 'same length of time' if window == 'custom' else window_label|lower|replace('last ', '') }} before, so no change is shown{% endif %} Updated {{ generated_at.strftime('%H:%M') }} UTC {% if not view.coverage.complete %}Partial read · {{ count(view.coverage.events) }} events{% else %}{{ count(view.coverage.events) }} events read{% endif %} {% if preserved_filters %}Trace selection kept · Clear{% endif %}

{% for entry in view.kpis %} {% if entry.href %}{% else %}
{% endif %} {{ entry.label }} {{ figure(entry) }} {{ delta(entry) }}{{ entry.note }}{% if entry.href and entry.label == 'Known spend' %} · Set prices{% endif %} {% if entry.href %}{% else %}
{% endif %} {% endfor %}
{% from '_usage_budget.html' import budget_panel %} {{ budget_panel(budget.status, can_edit=budget.can_edit, notice=budget.notice, error=budget.error) }}

{{ {'tokens': 'Tokens', 'spend': 'Known spend', 'calls': 'Model calls'}[metric] }} over time

{% if totals.calls %} {% set bar_format = '%b %d' if series.day_buckets else '%b %d %H:%M' %}
{% for bar in series.bars %} {% set when = bar.start.strftime(bar_format) ~ ('' if series.day_buckets else ' – ' ~ bar.end.strftime('%H:%M')) ~ (' ' ~ timezone_name.replace('_', ' ') if series.day_buckets and timezone_name != 'UTC' else ' UTC') %} {% set edge = ' ov-bar--start' if loop.index0 < series.bars|length * 0.2 else (' ov-bar--end' if loop.index0 >= series.bars|length * 0.8 else '') %} {% if bar.calls %} {% else %} {% endif %} {% endfor %}
{% if series.clipped %}

The newest {{ series.bars|length }} days are drawn; {{ series.clipped }} earlier ones are in the CSV by day.

{% endif %} {% if metric == 'spend' and totals.unpriced_calls %}

{{ count(totals.unpriced_calls) }} call{{ '' if totals.unpriced_calls == 1 else 's' }} without a price {{ 'is' if totals.unpriced_calls == 1 else 'are' }} left out of spend. Set prices

{% endif %} {% else %} {{ empty_state('No model calls in this window', 'Choose a longer range, or clear the agent and model filters.') }} {% endif %}

By agent

{{ view.agents|length }}
{% if view.agents %}
{% for row in view.agents %} 8 %} class="usage-extra"{% endif %}> {% endfor %}
AgentTokensCallsSpendp95
{% if row.filter_url %}{{ row.name }}{% else %}{{ row.name }}{% endif %} {% if not row.saved and row.agent_id %}Not saved in this store{% endif %} {% if row.unknown_usage_calls == row.calls %}Not reported{% else %}{{ fmt_compact(row.total_tokens) }}{% if row.unknown_usage_calls %}{{ row.unknown_usage_calls }} not reported{% endif %}{% endif %} {{ count(row.calls) }} {% if row.cost is not none %}{{ usd(row.cost) }}{% if row.unpriced_calls %}+{{ row.unpriced_calls }} unpriced{% endif %}{% else %}No price{% endif %} {{ fmt_duration(row.p95_latency_ms) }}
{% if view.agents|length > 8 %}{% endif %} {% else %}

No agent made a model call in this window.

{% endif %}

By model

{{ view.models|length }}
{% if view.models %}
{% for row in view.models %} 8 %} class="usage-extra"{% endif %}> {% endfor %}
ModelTokensCallsSpendp95
{{ row.model or row.label }}{{ row.provider }} {% if row.unknown_usage_calls == row.calls %}Not reported{% else %}{{ fmt_compact(row.total_tokens) }}{% if row.unknown_usage_calls %}{{ row.unknown_usage_calls }} not reported{% endif %}{% endif %} {{ count(row.calls) }} {% if row.cost is not none %}{{ usd(row.cost) }}{% endif %}{% if row.price_url %}{% if row.cost is not none %}+{{ row.unpriced_calls }} unpriced{% endif %} Set price{% endif %} {{ fmt_duration(row.p95_latency_ms) }}
{% if view.models|length > 8 %}{% endif %} {% else %}

No model calls in this window.

{% endif %}

Runs by spend and tokens

{% if view.run_count > view.runs|length %}{{ view.runs|length }} of {{ count(view.run_count) }} · export all{% else %}Export CSV{% endif %}
{% if view.runs %}
{% for row in view.runs %} 10 %} class="usage-extra"{% endif %}> {% endfor %}
StartedAgentCallsTokensSpendp95Trace
{{ relative_time(row.started, generated_at) if row.started else '—' }} {{ row.agent_name }} {{ count(row.calls) }} {% if row.unknown_usage_calls == row.calls %}Not reported{% else %}{{ fmt_compact(row.total_tokens) }}{% endif %} {% if row.cost is not none %}{{ usd(row.cost) }}{% else %}No price{% endif %} {{ fmt_duration(row.p95_latency_ms) }} {% if row.trace_url %}Trace{% endif %}
{% if view.runs|length > 10 %}{% endif %} {% else %}

No runs in this window.

{% endif %}
{% if coding_agents %}

Coding-agent sessions

Agent harnesses
{% for row in coding_agents %}{% endfor %}
AgentModelSessionsTurnsTokens inCachedTokens outSpend
{{ row.label }}{{ row.model or '—' }}{{ count(row.sessions) }}{{ count(row.turns) }}{{ fmt_compact(row.input_tokens) }}{{ fmt_compact(row.cached_tokens) }}{{ fmt_compact(row.output_tokens) }}{% if row.priced %}{{ usd(row.cost_usd) }}{% if row.priced < row.sessions %} + {{ row.sessions - row.priced }} unpriced{% endif %}{% else %}No price{% endif %}

Codex and Claude Code sessions the MemoRizz plugin recorded, read from each agent's own session log and counted apart from the usage above. Cost is Claude Code's own total, or OpenAI list rates for Codex when its model has one; a ChatGPT plan isn't billed per token.

{% endif %}

Memory in prompts

Approximate: rendered characters ÷ 4
{% if usage.memory %}
{{ donut(usage_charts.memory_tokens, 'Share of memory tokens supplied') }} {{ bars(usage_charts.memory_latency, 'Retrieval time', 'mean per read', kind='ms') }}
Every memory type
{% for row in usage.memory %}{% endfor %}
Memory typeApprox. tokensTimes suppliedReadsRead errorsMean readp95 read
{{ memory_label(row.label) }}{{ count(row.memory_tokens_estimate) if row.supply_samples else '—' }}{{ count(row.supply_samples) }}{{ count(row.retrieval_samples) }}{{ count(row.retrieval_errors) }}{{ fmt_duration(row.retrieval_mean_ms) }}{{ fmt_duration(row.retrieval_p95_ms) }}
{% else %}

No memory measurements in this window. Agents record them when they read memory for a prompt.

{% endif %}
{% set cache = usage.prompt_cache %}

Provider prompt cache

{% if cache.read_percent is not none %}{{ percent(cache.read_percent) }} of input read from cache{% else %}Not reported by these models{% endif %}
{% with trace_analysis = false %}{% include '_prompt_cache.html' %}{% endwith %}

How these figures are counted

{{ count(view.coverage.events) }} events · {{ 'complete' if view.coverage.complete else 'partial' }} read
{% endblock %}