{% extends "base.html" %} {% block title %}API Activity — Job Cannon{% endblock %} {% block content %}

API Activity

{% if view == 'usage' %} {# ====================================================================== #} {# USAGE VIEW — tokens in/out across all providers (incl. free/CLI/local). #} {# ====================================================================== #}
{% if top_purpose_insight %}

{{ top_purpose_insight.purpose }} drives {{ "%.0f" | format(top_purpose_insight.share_pct) }}% of output tokens (last 30 days)

{{ "{:,}".format(top_purpose_insight.share_tokens) }} of {{ "{:,}".format(top_purpose_insight.total_tokens) }} tokens · all providers (Ollama, Claude CLI, Anthropic SDK, etc.)

{% else %}

Output Tokens by Purpose (30 Days)

Includes every provider — Ollama, Claude CLI, Anthropic SDK, etc.

{% endif %}
{% for label, key in [('Today', 'today'), ('This Week', 'week'), ('This Month', 'month'), ('Projected / mo', 'projected_monthly')] %} {% set s = usage_stats[key] %}
{{ label }}
{{ "{:,}".format(s.calls) }}calls
In
{{ "{:,}".format(s.input_tokens) }}
Out
{{ "{:,}".format(s.output_tokens) }}
{% endfor %}

This Month by Feature

{% if monthly_feature_usage %} {# Column maxes drive the bar-in-cell widths; computed once per render. #} {% set feat_max_calls = (monthly_feature_usage | map(attribute='calls') | max) or 1 %} {% set feat_max_input = (monthly_feature_usage | map(attribute='input_tokens') | max) or 1 %} {% set feat_max_output = (monthly_feature_usage | map(attribute='output_tokens') | max) or 1 %} {% for item in monthly_feature_usage %} {% set call_pct = (item.calls / feat_max_calls * 100) %} {% set in_pct = (item.input_tokens / feat_max_input * 100) %} {% set out_pct = (item.output_tokens / feat_max_output * 100) %} {% endfor %}
Feature Calls Input tokens Output tokens
{{ item.purpose }} {{ "{:,}".format(item.calls) }} {{ "{:,}".format(item.input_tokens) }} {{ "{:,}".format(item.output_tokens) }}
{% else %}

No API calls this month.

{% endif %}

This Month by Provider

{% if monthly_provider_usage %} {% set prov_max_calls = (monthly_provider_usage | map(attribute='calls') | max) or 1 %} {% set prov_max_input = (monthly_provider_usage | map(attribute='input_tokens') | max) or 1 %} {% set prov_max_output = (monthly_provider_usage | map(attribute='output_tokens') | max) or 1 %} {% for item in monthly_provider_usage %} {% set call_pct = (item.calls / prov_max_calls * 100) %} {% set in_pct = (item.input_tokens / prov_max_input * 100) %} {% set out_pct = (item.output_tokens / prov_max_output * 100) %} {% endfor %}
Provider Calls Input tokens Output tokens
{{ item.provider }} {{ "{:,}".format(item.calls) }} {{ "{:,}".format(item.input_tokens) }} {{ "{:,}".format(item.output_tokens) }}
{% else %}

No API calls this month.

{% endif %}
{% else %} {# ====================================================================== #} {# COST VIEW — paid providers only. Subscription/free rows excluded by SQL #} {# in get_cost_stats / get_*_breakdown (FREE_PROVIDERS filter, mirroring #} {# cost_gate semantics). #} {# ====================================================================== #}

API Spend by Feature (30 Days)

Subscription & CLI paths ($0) excluded. Switch to Usage view to see all activity.

{% if budget_pct >= 100 %} {% set bar_color = "bg-red-500" %} {% set pct_text = "text-red-400" %} {% elif budget_pct >= 80 %} {% set bar_color = "bg-amber-500" %} {% set pct_text = "text-amber-400" %} {% else %} {% set bar_color = "bg-emerald-500" %} {% set pct_text = "text-emerald-400" %} {% endif %}

Daily Budget Usage

{{ "%.0f" | format(budget_pct) }}% of daily cap used
Today's spend: ${{ "%.4f" | format(cost_stats.today) }} Daily cap: ${{ "%.0f" | format(budget_cap) }}
Today
${{ "%.3f" | format(cost_stats.today) }}
This Week
${{ "%.3f" | format(cost_stats.week) }}
This Month
${{ "%.2f" | format(cost_stats.month) }}
Projected / mo
${{ "%.2f" | format(cost_stats.projected_monthly) }}

This Month by Feature

{% if monthly_breakdown %} {% set cf_max_calls = (monthly_breakdown | map(attribute='calls') | max) or 1 %} {% set cf_max_spend = (monthly_breakdown | map(attribute='spend') | max) or 1 %} {% for item in monthly_breakdown %} {% set call_pct = (item.calls / cf_max_calls * 100) %} {% set spend_pct = (item.spend / cf_max_spend * 100) %} {% endfor %}
Feature Calls Spend
{{ item.purpose }} {{ item.calls }} ${{ "%.4f" | format(item.spend) }}
{% else %}

No paid API calls this month.

{% endif %}

This Month by Provider

{% if monthly_provider_breakdown %} {% set cp_max_calls = (monthly_provider_breakdown | map(attribute='calls') | max) or 1 %} {% set cp_max_spend = (monthly_provider_breakdown | map(attribute='spend') | max) or 1 %} {% for item in monthly_provider_breakdown %} {% set call_pct = (item.calls / cp_max_calls * 100) %} {% set spend_pct = (item.spend / cp_max_spend * 100) %} {% endfor %}
Provider Calls Spend
{{ item.provider }} {{ item.calls }} ${{ "%.4f" | format(item.spend) }}
{% else %}

No paid API calls this month.

{% endif %}
{% endif %}
{% endblock %} {% block extra_scripts %} {% if view == 'usage' %} {% else %} {% endif %} {% endblock %}