{# Reusable token-usage-by-model card. Expects a ``token_usage`` dict built by app._token_usage_view(); optional ``token_usage_title`` overrides the heading. #} {% if token_usage and token_usage.has_data %}

{{ token_usage_title or 'Token usage by model' }}

{{ '{:,}'.format(token_usage.total_tokens) }} tokens in {{ '{:,}'.format(token_usage.total_input) }} · out {{ '{:,}'.format(token_usage.total_output) }} · {{ token_usage.total_calls }} calls {% if token_usage.cache_hit_pct is not none %} ↻ {{ token_usage.cache_hit_pct }}% cached {% endif %} {% if token_usage.estimated_calls %} {{ token_usage.estimated_calls }} estimated {% endif %} {% if token_usage.missing_calls %} {{ token_usage.missing_calls }} missing {% endif %}
{% for m in token_usage.by_model %} {# '—' means the provider reported no cache details; 0.0% is a measured miss. #} {% endfor %}
Model Input Output Total Cached in Cache hit Calls Quality
{{ m.model or '—' }} {{ '{:,}'.format(m.input_tokens or 0) }} {{ '{:,}'.format(m.output_tokens or 0) }} {{ '{:,}'.format(m.total_tokens or 0) }}{% if m.cache_hit_pct is not none %}{{ '{:,}'.format(m.cached_input_tokens or 0) }}{% else %}—{% endif %} {% if m.cache_hit_pct is not none %}{{ m.cache_hit_pct }}%{% else %}—{% endif %} {{ m.calls or 0 }} {% if not m.estimated_usage and not m.missing_usage %} exact {% else %} {% if m.estimated_usage %}{{ m.estimated_usage }} est{% endif %} {% if m.missing_usage %}{{ m.missing_usage }} missing{% endif %} {% endif %}
{% if token_usage.incomplete_reason %}

⚠ This per-request summary may be incomplete: {{ token_usage.incomplete_reason }}

{% endif %}
{% endif %}