Calculation Backend decision 12

Per-provider cost precision: whole cents vs. nano-precision

Providers store per-prompt cost at different precisions, and for different reasons — this is not one rule applied three times, it is three separate calls. A shared constraint underlies all three: cost is always stored as an integer column, never as floating point, to avoid the rounding inconsistencies float storage would introduce. What differs is which integer granularity each provider’s column uses.

Claude rounds the cost of a single prompt to a whole cent at ingest time and stores it as an integer cent column. This is safe because Claude’s per-prompt costs are almost always well above a cent — whole-cent rounding loses nothing meaningful there.

OpenCode stores cost as NanoCent, at a billion-times-finer resolution than a cent. Here a meaningful share of individual prompts cost less than one cent; rounding such a prompt to the nearest whole cent at ingest would store it as 0 and permanently discard cost that was actually incurred. Nano-precision keeps that value intact until it is summed with others, where it can add up to something significant.

Copilot stores cost as NanoAiu, for a third, independent reason: the plugin already reports the cost from GitHub’s own billing unit (the AI-Unit) at that same nano-scale precision, as an integer. Storing it as-is avoids an unnecessary rounding step, and keeps the AI-Unit available for other uses later — for example, if a CO2 factor is ever defined per AI-Unit. Whether Copilot’s own per-prompt costs frequently fall below a cent is not the deciding factor here, unlike for OpenCode.

A future provider should be evaluated on its own terms — its own per-prompt cost distribution, and the precision its own source data already provides — not assumed to match any existing provider’s reasoning.

This is a different situation from decision 10 (missing price/CO₂ factor defaults to 0): there, the price is absent from the lookup table. Here, the price is present and applied correctly — the cost is genuinely below the rounding threshold and rounds down to a stored 0. Do not go looking for a missing price row for this case; there isn’t one.