|
| 1 | +{ |
| 2 | + "_purpose": "Canonical golden vectors for the claude-carbon methodology. Source of truth shared with downstream consumers (TokenClimate SaaS keeps a byte-identical copy in tests/fixtures/ and checks it weekly). Any change to data/factors.json or data/prices.json MUST update these expected values in the same commit.", |
| 3 | + "_formulas": { |
| 4 | + "co2_grams": "((input_tokens + cache_creation_tokens) * factor_in + cache_read_tokens * (factor_in * cache_read_factor) + output_tokens * factor_out) / 1e6", |
| 5 | + "cost_usd": "(input_tokens * price_in + cache_creation_tokens * (price_in * cache_write_multiplier) + cache_read_tokens * (price_in * cache_read_multiplier) + output_tokens * price_out) / 1e6" |
| 6 | + }, |
| 7 | + "_token_semantics": "input_tokens here is the UNCACHED input (Anthropic usage.input_tokens). cache_creation_tokens (cache write) is separate. Note: the plugin DB column input_tokens stores input + cache_write; these vectors keep them split, as captured from the JSONL.", |
| 8 | + "_constants": { |
| 9 | + "cache_read_factor": 0.08, |
| 10 | + "cache_write_multiplier": 1.25, |
| 11 | + "cache_read_multiplier": 0.1, |
| 12 | + "factors_gco2e_per_mtok": { |
| 13 | + "fable": { "input": 1000, "output": 6000 }, |
| 14 | + "opus": { "input": 500, "output": 3000 }, |
| 15 | + "sonnet": { "input": 190, "output": 1140 }, |
| 16 | + "haiku": { "input": 95, "output": 570 } |
| 17 | + }, |
| 18 | + "prices_usd_per_mtok": { |
| 19 | + "fable": { "input": 10, "output": 50 }, |
| 20 | + "opus": { "input": 5, "output": 25 }, |
| 21 | + "sonnet": { "input": 3, "output": 15 }, |
| 22 | + "haiku": { "input": 1, "output": 5 } |
| 23 | + } |
| 24 | + }, |
| 25 | + "_rounding": "All token counts are multiples of 10,000 so every expected value is EXACT at <= 3 decimals for co2_grams and <= 4 decimals for cost_usd. This makes the vectors implementation-agnostic: the bash plugin prints co2 at 4 decimals / cost at 6 decimals, the SaaS rounds co2 to 3 decimals / cost to 4 decimals, and both land on the exact value. Runners compare with a relative tolerance of 1e-6.", |
| 26 | + "_excluded_semantics": "Vectors with excluded=true use a model string without 'claude' (or matching factors.json exclude_models). expected_* is null: the bash plugin stores co2_grams=0 / cost_usd=0 with excluded=1 (raw tokens kept, no estimate); the SaaS returns null ('CO2 non connu'). Both mean: no number is fabricated.", |
| 27 | + "vectors": [ |
| 28 | + { |
| 29 | + "id": "fable-mixed", |
| 30 | + "description": "Fable 5, full mix of all four token kinds", |
| 31 | + "model": "claude-fable-5", |
| 32 | + "input_tokens": 50000, |
| 33 | + "cache_creation_tokens": 200000, |
| 34 | + "cache_read_tokens": 3000000, |
| 35 | + "output_tokens": 30000, |
| 36 | + "expected_co2_grams": 670.0, |
| 37 | + "expected_cost_usd": 7.5 |
| 38 | + }, |
| 39 | + { |
| 40 | + "id": "opus-no-cache", |
| 41 | + "description": "Opus, plain input/output, no cache traffic", |
| 42 | + "model": "claude-opus-4-6", |
| 43 | + "input_tokens": 1000000, |
| 44 | + "cache_creation_tokens": 0, |
| 45 | + "cache_read_tokens": 0, |
| 46 | + "output_tokens": 100000, |
| 47 | + "expected_co2_grams": 800.0, |
| 48 | + "expected_cost_usd": 7.5 |
| 49 | + }, |
| 50 | + { |
| 51 | + "id": "sonnet-cache-read-dominant", |
| 52 | + "description": "Sonnet, cache_read dominant - shape of a real Claude Code session (dated model id resolved by family pattern)", |
| 53 | + "model": "claude-sonnet-4-5-20250929", |
| 54 | + "input_tokens": 20000, |
| 55 | + "cache_creation_tokens": 150000, |
| 56 | + "cache_read_tokens": 12000000, |
| 57 | + "output_tokens": 80000, |
| 58 | + "expected_co2_grams": 305.9, |
| 59 | + "expected_cost_usd": 5.4225 |
| 60 | + }, |
| 61 | + { |
| 62 | + "id": "haiku-mixed", |
| 63 | + "description": "Haiku, full mix of all four token kinds", |
| 64 | + "model": "claude-3-5-haiku", |
| 65 | + "input_tokens": 40000, |
| 66 | + "cache_creation_tokens": 10000, |
| 67 | + "cache_read_tokens": 500000, |
| 68 | + "output_tokens": 20000, |
| 69 | + "expected_co2_grams": 19.95, |
| 70 | + "expected_cost_usd": 0.2025 |
| 71 | + }, |
| 72 | + { |
| 73 | + "id": "opus-cache-write-only", |
| 74 | + "description": "Opus, cache_write only: full input factor for CO2, 1.25x input price", |
| 75 | + "model": "claude-opus-4-6", |
| 76 | + "input_tokens": 0, |
| 77 | + "cache_creation_tokens": 100000, |
| 78 | + "cache_read_tokens": 0, |
| 79 | + "output_tokens": 0, |
| 80 | + "expected_co2_grams": 50.0, |
| 81 | + "expected_cost_usd": 0.625 |
| 82 | + }, |
| 83 | + { |
| 84 | + "id": "sonnet-cache-read-only", |
| 85 | + "description": "Sonnet, cache_read only: 0.08x input factor for CO2, 0.1x input price", |
| 86 | + "model": "claude-sonnet-4", |
| 87 | + "input_tokens": 0, |
| 88 | + "cache_creation_tokens": 0, |
| 89 | + "cache_read_tokens": 1000000, |
| 90 | + "output_tokens": 0, |
| 91 | + "expected_co2_grams": 15.2, |
| 92 | + "expected_cost_usd": 0.3 |
| 93 | + }, |
| 94 | + { |
| 95 | + "id": "all-zeros", |
| 96 | + "description": "Known model, zero tokens everywhere", |
| 97 | + "model": "claude-sonnet-4", |
| 98 | + "input_tokens": 0, |
| 99 | + "cache_creation_tokens": 0, |
| 100 | + "cache_read_tokens": 0, |
| 101 | + "output_tokens": 0, |
| 102 | + "expected_co2_grams": 0.0, |
| 103 | + "expected_cost_usd": 0.0 |
| 104 | + }, |
| 105 | + { |
| 106 | + "id": "excluded-non-claude-model", |
| 107 | + "description": "Non-Anthropic model (e.g. local model behind ANTHROPIC_BASE_URL): no estimate is fabricated", |
| 108 | + "model": "glm-4.7-flash", |
| 109 | + "input_tokens": 100000, |
| 110 | + "cache_creation_tokens": 50000, |
| 111 | + "cache_read_tokens": 2000000, |
| 112 | + "output_tokens": 40000, |
| 113 | + "excluded": true, |
| 114 | + "expected_co2_grams": null, |
| 115 | + "expected_cost_usd": null |
| 116 | + }, |
| 117 | + { |
| 118 | + "id": "fable-mythos-alias", |
| 119 | + "description": "Fable family via the mythos model id", |
| 120 | + "model": "claude-mythos-5", |
| 121 | + "input_tokens": 10000, |
| 122 | + "cache_creation_tokens": 0, |
| 123 | + "cache_read_tokens": 0, |
| 124 | + "output_tokens": 10000, |
| 125 | + "expected_co2_grams": 70.0, |
| 126 | + "expected_cost_usd": 0.6 |
| 127 | + }, |
| 128 | + { |
| 129 | + "id": "opus-heavy-session", |
| 130 | + "description": "Opus, large session with heavy cache traffic", |
| 131 | + "model": "claude-opus-4-7", |
| 132 | + "input_tokens": 30000, |
| 133 | + "cache_creation_tokens": 400000, |
| 134 | + "cache_read_tokens": 8000000, |
| 135 | + "output_tokens": 60000, |
| 136 | + "expected_co2_grams": 715.0, |
| 137 | + "expected_cost_usd": 8.15 |
| 138 | + }, |
| 139 | + { |
| 140 | + "id": "haiku-tiny-session", |
| 141 | + "description": "Haiku, small symmetric session, no cache", |
| 142 | + "model": "claude-haiku", |
| 143 | + "input_tokens": 10000, |
| 144 | + "cache_creation_tokens": 0, |
| 145 | + "cache_read_tokens": 0, |
| 146 | + "output_tokens": 10000, |
| 147 | + "expected_co2_grams": 6.65, |
| 148 | + "expected_cost_usd": 0.06 |
| 149 | + }, |
| 150 | + { |
| 151 | + "id": "haiku-cache-read-only", |
| 152 | + "description": "Haiku, large cache_read only", |
| 153 | + "model": "claude-3-5-haiku", |
| 154 | + "input_tokens": 0, |
| 155 | + "cache_creation_tokens": 0, |
| 156 | + "cache_read_tokens": 10000000, |
| 157 | + "output_tokens": 0, |
| 158 | + "expected_co2_grams": 76.0, |
| 159 | + "expected_cost_usd": 1.0 |
| 160 | + } |
| 161 | + ] |
| 162 | +} |
0 commit comments