<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nio_zang@hotmail.com zang</title>
    <description>The latest articles on DEV Community by nio_zang@hotmail.com zang (@nio_zanghotmailcom_zang).</description>
    <link>https://dev.to/nio_zanghotmailcom_zang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4109319%2Fa8560df4-0239-48a1-90aa-67cc43bf3efa.png</url>
      <title>DEV Community: nio_zang@hotmail.com zang</title>
      <link>https://dev.to/nio_zanghotmailcom_zang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nio_zanghotmailcom_zang"/>
    <language>en</language>
    <item>
      <title>tokeneff: An Open-Source LLM Cost Meter That Runs Locally</title>
      <dc:creator>nio_zang@hotmail.com zang</dc:creator>
      <pubDate>Sun, 13 Sep 2026 02:10:15 +0000</pubDate>
      <link>https://dev.to/nio_zanghotmailcom_zang/tokeneff-an-open-source-llm-cost-meter-that-runs-locally-5440</link>
      <guid>https://dev.to/nio_zanghotmailcom_zang/tokeneff-an-open-source-llm-cost-meter-that-runs-locally-5440</guid>
      <description>&lt;p&gt;&lt;strong&gt;Most LLM dashboards show you the bill &lt;em&gt;after&lt;/em&gt; the damage is done.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You run a coding agent for an afternoon, ship a feature, and two days later your&lt;br&gt;
OpenAI dashboard says you spent $47. On what? Which model? Which request? You&lt;br&gt;
have no idea — and by then it's too late to do anything about it.&lt;/p&gt;

&lt;p&gt;This is the problem we kept hitting, so we built &lt;strong&gt;&lt;a href="https://github.com/zangxin75/token-efficiency" rel="noopener noreferrer"&gt;tokeneff&lt;/a&gt;&lt;/strong&gt; — an open-source CLI that puts a real-time electricity meter on your LLM API spend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;⚡ tokeneff 电表  (CNY)

  今日花费       ¥0.0284
  本月累计       ¥0.2524
  月终预测       ~¥0.93 (100% 置信)
  累计节省       ¥0.0421

  今日模型花费分布
  deepseek-v4-flash  ¥0.0192   15,797 tok
  glm-4-flash        ¥0.0092    8,273 tok
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tokeneff&lt;/code&gt; runs a tiny local proxy on &lt;code&gt;localhost:7860&lt;/code&gt;. You point your LLM client's &lt;code&gt;base_url&lt;/code&gt; at it, and it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Routes&lt;/strong&gt; your request to the upstream provider (OpenAI, DeepSeek, GLM, Kimi, MiniMax, Anthropic) using &lt;strong&gt;your own API key&lt;/strong&gt; — BYOK, the key never leaves your machine&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adapts&lt;/strong&gt; request formats automatically (OpenAI ↔ Anthropic conversion)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meters&lt;/strong&gt; the token usage from the response&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calculates&lt;/strong&gt; cost locally using a bundled pricing table — official price vs what you actually pay&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stores&lt;/strong&gt; the record in a local SQLite DB (token counts only — &lt;strong&gt;never your prompts&lt;/strong&gt;)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;your client → tokeneff proxy (localhost:7860) → LLM upstream
                   ↓
              local SQLite meter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a transparent pipe. Your requests still go direct to the provider; tokeneff just reads the &lt;code&gt;usage&lt;/code&gt; counts from the response and keeps a running tab.&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes it different
&lt;/h2&gt;

&lt;p&gt;There are a few LLM cost trackers on GitHub already. Here's where tokeneff fits:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;tokeneff&lt;/th&gt;
&lt;th&gt;toktrack&lt;/th&gt;
&lt;th&gt;tokencost&lt;/th&gt;
&lt;th&gt;LLM-Cost-Guardian&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Capture method&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;local proxy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;reads CLI logs&lt;/td&gt;
&lt;td&gt;manual / proxy&lt;/td&gt;
&lt;td&gt;local proxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real-time token count&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Month-end forecast&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dual region / currency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BYOK + platform dual-mode&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Budget alerts&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things nobody else does:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Month-end forecast
&lt;/h3&gt;

&lt;p&gt;The killer feature. Based on your usage trend (weighted: last 7 days × 70% + linear extrapolation × 30%), it predicts what you'll spend by month-end — with a confidence score. Seven days of data and it locks in. "At this rate, I'll hit $31 by the 31st" is the kind of number that actually changes behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dual region / currency
&lt;/h3&gt;

&lt;p&gt;If you're a Chinese developer using DeepSeek/GLM/Kimi, your spend is in CNY ¥. If you're using OpenAI/Claude, it's in USD $. Most tools mash these together into one meaningless number. tokeneff tracks them &lt;strong&gt;separately&lt;/strong&gt; — CNY spend and USD spend are never mixed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. BYOK + platform dual-mode
&lt;/h3&gt;

&lt;p&gt;BYOK mode is 100% free and local — your keys, your upstream, zero markup. But there's also a &lt;strong&gt;platform mode&lt;/strong&gt; that routes through the TokenEff gateway (one key, all models, wholesale pricing). The meter shows the savings: official price vs platform price, side by side. You switch when it makes sense, not when you're forced to.&lt;/p&gt;

&lt;h2&gt;
  
  
  The privacy angle
&lt;/h2&gt;

&lt;p&gt;This matters more than people admit. A cost tracker that sends your request metadata to a cloud service to compute your bill is... not great. tokeneff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stores &lt;strong&gt;only&lt;/strong&gt; token counts, model name, cost, timestamp&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never&lt;/strong&gt; stores prompt content or completions&lt;/li&gt;
&lt;li&gt;Runs entirely locally — &lt;code&gt;~/.tokeneff/meter.db&lt;/code&gt; is a SQLite file you can &lt;code&gt;rm&lt;/code&gt; anytime&lt;/li&gt;
&lt;li&gt;API keys live in the OS keyring, never plaintext on disk&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;tokeneff
tokeneff setup          &lt;span class="c"&gt;# pick provider, paste key&lt;/span&gt;
tokeneff start          &lt;span class="c"&gt;# starts the proxy on :7860&lt;/span&gt;
tokeneff stats          &lt;span class="c"&gt;# see the meter&lt;/span&gt;
tokeneff dashboard      &lt;span class="c"&gt;# live TUI (refreshes every 0.5s)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Point your client at &lt;code&gt;http://localhost:7860/v1&lt;/code&gt; and start building. Watch the meter while you work — not after.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ubuntu 22.04 gotcha:&lt;/strong&gt; the default &lt;code&gt;setuptools&lt;/code&gt; (59.6.0) is too old for PEP 621 and installs as &lt;code&gt;UNKNOWN-0.0.0&lt;/code&gt;. Run &lt;code&gt;pip install --user --upgrade "setuptools&amp;gt;=70"&lt;/code&gt; first. (Yes, this is in the README too.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Richer TUI&lt;/strong&gt; — per-model trend charts, request-level drill-down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More providers&lt;/strong&gt; — community-contributable registry&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost comparison reports&lt;/strong&gt; — "run this task on 5 models, here's what each costs"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Star ⭐ the &lt;a href="https://github.com/zangxin75/token-efficiency" rel="noopener noreferrer"&gt;repo&lt;/a&gt; if this solves a problem for you. Issues and PRs welcome — especially new provider additions.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Building tokeneff as part of a broader open-source LLM gateway stack. BYOK meter first, gateway later. The meter is and will remain free + local.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cli</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
