Files
ai-agent/docs/local-energy.md
gabrielvidalandClaude Opus 5.5 acda5ecc30 refactor: retire core leftovers the plugins replaced
- frontend: drop the dead Conversations dashboard code (costAnalysis,
  DashboardFilters, ConversationsDashboard), the unused analytics /
  footprint / pricing helpers, the orphan api.ts comment and the dead
  mocks (perf dashboard, storage dashboard, telemetry hub/usage,
  usage daily/history/calibration); their French strings
- backend: drop look.parse_action (the conversation-labels plugin has its
  own) and UsersStore.emails() (no caller)
- routes: drop GET /api/usage/daily|history|calibration,
  GET /api/telemetry/usage, GET /api/goals, POST /api/goal-work — the
  plugin bridges call daily_usage, calibrate.history, views.usage,
  goals_list and goal_work directly; authz table + golden matrix updated;
  openapi.json re-dumped, src/generated regenerated
- FALLBACK_ACCOUNTS: one neutral Claude seat instead of a stale copy of
  the providers' profiles (the full list moves to mock/accounts.ts)
- notify CLI: no local PRICES estimate — the line is
  "Claude Code · 78k tokens · 8m" and the hub's restate_cost puts the
  run's exact list price in (an older CLI's $ line is still restated)
- CLAUDE.md / docs / docstrings: scheduled/, templates/, sidecar
  *_usage.py, the clarifier (now the plugin's agents[] + prefs),
  runs/extras.py, sidecar/routes_chrome.py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 11:53:15 +01:00

5.2 KiB
Raw Permalink Blame History

What a local run costs

A conversation on the EVOX2's local models (pi's evox2 provider and its opencode twins evox2/<id>, served by the box's llm-server) has no API price. pi records costUSD: 0 for it. Its real cost is the box's time: the electricity the box draws while it works, plus a share of the box itself. The provider-evox2 plugin's local_energy pricing (read through backend/conversations/pricing.py → local_call) prices every local call that way, and the parser uses that price instead of the runner's zero.

The formula

For one call that kept the box busy for t seconds:

Wh          = W(model) × t / 3600
electricity = Wh / 1000 × tariff(date of the call)                 €
hardware    = t / 3600 × 2049 € / (5 years × busy hours per year)   €
cost        = (electricity + hardware) × USD_PER_EUR               $ (the book's unit)
  • t is the call's wall-clock duration, timed the way the parser times every call (turn_ms): from the transcript record that unblocked it (the prompt, or the last tool result) to the reply. An opencode step writes its usage only after its tools have run, so its duration comes from the step's first (content) record (_unpriced[…]["ms"]), not from the usage record. Anything longer than an hour is treated as a stall and capped there.
  • Time, not tokens. llm-server reuses its prompt cache without reporting it, so a run's token counts don't track how long the box worked. The qwen 3.6 runs to date billed 116 M input tokens in all; prefilling those cold would have taken ~40 h, but the box worked 15.6 h.
  • Full wall power. The ~9 W the box draws while idle counts too: that is what the plug measures while the model works.
  • Hardware. Gabriel's choice (2026-11-01 form): €2049, straight-line over 5 years, spread over the hours the box is busy (above 30 W), not over every hour of the year. At ~7 % utilisation that makes a busy hour cost ~€0.67 of hardware against ~€0.02 of electricity. Utilisation drives the local cost, not the electricity price.
  • Tokens stay free (OTHER_PRICES["qwen-local"] = 0) and count for no plan. The hourly meterBins, which feed the plan calibration, leave local calls out.

The measurements (2026-10-09 → 11-01, Performance mode)

The source is the Tuya plug under the box → Home Assistant sensor.evox2_wall_power (services/home-assistant/config/packages/evox2_power.yaml in the homelab; it reads 0 W while the plug is off) → Prometheus homeassistant_sensor_power_w, kept 30 days.

qwen 3.6 35B-A3B, during its calls 111 W (13.8 h of calls)
qwen 3.8 27B 116 W (2.8 h)
qwen 3.8 Flash-Next Coder 138 W (0.4 h)
any other local model 112 W (the pricing's defaultWatts)
awake, idle 9 W (median)
asleep / plug off ≤ 5 W
busy (> 30 W) 38 h in 22.9 days → 613 h/year
the whole box, 22.9 days 7.2 kWh ≈ €1.44

Re-fit them with:

scripts/local-energy-calibration.py                 # last 30 days (Prometheus' retention)
scripts/local-energy-calibration.py --since 2026-10-15 --json out.json

It prints the per-model mean wall power over the calls' windows (only windows that hold a plug sample), the busy hours per year and the idle draw. Copy the figures into the provider-evox2 plugin by hand (each model's watts, the pricing's busyHoursPerYear), bump its pricing bookDate, and bump the indexer's PARSER_VERSION so every stored summary is re-priced.

The tariff

electricityTariffs (in provider-evox2's pricing) is a dated table: EDF Tarif Bleu, option Base, 6 kVA, TTC. Each call is priced at the tariff in force on its own date. The regulated tariff changes on 1 February and 1 August; add one line each time (and bump PARSER_VERSION). Values: 0.1940 € from 2026-02-01, 0.2001 € from 2026-08-01.

The book is in USD, and € converts at USD_PER_EUR = 1 / 0.92, the frontend's default usdToEur. With that default, a € shown in the app matches the € entered in the book.

Where it shows

  • The summary's local field (seconds, wh, electricity, hardware; USD) is set whenever a local model ran, and cost includes it everywhere: cards, totals, dashboards, project and skill rollups.
  • On a conversation card, a ⚡ Wh chip sits under the cost, in the slot the plan-% chip takes on Claude runs. Its tooltip splits electricity from hardware.
  • The Details drawer has an EVOX2 time card: box time, electricity with its Wh, hardware.
  • Footprint comes from the measured kWh, not the Claude token factors: France's consumption mix, 0.0461 kgCO2e/kWh (ADEME Base Empreinte, « Électricité 2025 – mix moyen – consommation »). Water is the Jegham et al. off-site WUE only (3.142 L/kWh); there is no data-centre cooling at home. The dashboards apply the Claude token estimate only to the Claude models of such a run. analytics.modelFamily files every other id under "opus", which would otherwise charge a local run Opus's carbon.
  • In the token-type split, a local model's cost is divided by the box's time per token type: llm-server decodes ~16× slower than it prefills, and its prompt cache is free (projects/costs.py, pricing.local_output_weight).