/token-cost — estimate the floor cost of a self-hosted LLM token: electricity
plus hardware amortization. This is the physical lower bound (the "bedrock"), not the
market API price. Based on the article
Почём нынче токен для народа? by Pavel Rykov.
The skill gathers the formula inputs by querying the server where it can and asking the user for the rest, then prints cost per 1M input/output tokens.
C_1M = ((P_kW * T_kWh + S / H_life) * 1e6) / (R_tok_s * 3600)
| Symbol | Meaning | Source |
|---|---|---|
P_kW |
real power draw under load (kW) | measured (nvidia-smi) |
T_kWh |
electricity tariff (RUB/kWh) | asked |
R_tok_s |
speed, decode for output / prefill for input (tok/s) | measured (benchmark) |
S |
hardware cost (RUB) | asked |
H_life |
lifetime hours = years × 365 × 24 | asked (default 5 y) |
Input and output are computed separately; idle utilization raises the amortization share per useful token.
| File | Purpose |
|---|---|
SKILL.md |
Agent instructions (frontmatter name, version, description). |
scripts/token_cost.py |
Math + measure-power (samples nvidia-smi). stdlib only. |
scripts/bench_speed.py |
Measures decode/prefill tok/s against an OpenAI-compatible endpoint. stdlib only. |
# Measure real power while the model is generating
python3 scripts/token_cost.py measure-power --overhead-w 150
# Measure speed against the running endpoint (vLLM / llama.cpp / NeuralDeep)
python3 scripts/bench_speed.py --base-url http://localhost:8000 --model gpt-oss-120b
# Full estimate with amortization
python3 scripts/token_cost.py compute \
--measure-power --tariff 6.97 \
--decode-tok-s 90 --prefill-tok-s 1440 \
--hw-cost 700000 --life-years 5 --utilization 1.0Reference example (2×RTX 4090 48 GB, GPT-OSS-120B, Saint Petersburg tariff) reproduces the article: ≈10.76 RUB/1M output by electricity, ≈60 RUB/1M output with 5-year amortization.
This skill is distributed through the rpa-skills catalog (a Claude Code plugin marketplace), and also installs as a plain skill folder (Cursor, OpenAI Codex, Kimi Code CLI, and others).
As a plugin (Claude Code) — add the catalog once, then install this skill from it:
/plugin marketplace add EvilFreelancer/rpa-skills
/plugin install token-cost@rpa-skills
As a plain skill folder — copy or symlink this repository into a skill root (its SKILL.md lives at the repo root):
| Tool | Path |
|---|---|
| Claude Code | ~/.claude/skills/token-cost/ |
| Cursor | ~/.cursor/skills/token-cost/ |
| OpenAI Codex | ~/.codex/skills/token-cost/ |
| Kimi Code CLI | ~/.kimi/skills/token-cost/ |
The directory name must match the name field in SKILL.md.
- Slash command — type
/token-costin agent chat. @context — attach the skill folder orSKILL.md.- Automatic — the agent may load it when your request matches the
descriptioninSKILL.md.
Part of rpa-skills — Pavel Rykov's agent-skills collection (see notes on vibe coding and the prompt collection cursor-vibe-prompts).
Based on the article Почём нынче токен для народа? by Pavel Rykov.
Licensed under the MIT License — see LICENSE.