<?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>Forem: followtayeeb</title>
    <description>The latest articles on Forem by followtayeeb (@followtayeeb).</description>
    <link>https://forem.com/followtayeeb</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813494%2Fff46d11e-3676-42bd-bffb-e87a204ca034.png</url>
      <title>Forem: followtayeeb</title>
      <link>https://forem.com/followtayeeb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/followtayeeb"/>
    <language>en</language>
    <item>
      <title>I Built an Open-Source CLI to Compare LLM API Costs in Your Terminal (npx, Zero Install)</title>
      <dc:creator>followtayeeb</dc:creator>
      <pubDate>Sun, 08 Mar 2026 21:49:41 +0000</pubDate>
      <link>https://forem.com/followtayeeb/i-built-an-open-source-cli-to-compare-llm-api-costs-in-your-terminal-npx-zero-install-47mk</link>
      <guid>https://forem.com/followtayeeb/i-built-an-open-source-cli-to-compare-llm-api-costs-in-your-terminal-npx-zero-install-47mk</guid>
      <description>&lt;p&gt;If you've ever had to compare costs between GPT-4o, Claude Sonnet, and Gemini before committing to a model, you know the pain: browser tabs, manual math, outdated blog posts.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;llm-costs&lt;/strong&gt; — a zero-install CLI that does it instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Every time I start a new project using LLMs, I go through the same ritual:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Anthropic pricing page&lt;/li&gt;
&lt;li&gt;Open OpenAI pricing page
&lt;/li&gt;
&lt;li&gt;Open Google AI pricing page&lt;/li&gt;
&lt;li&gt;Try to compare apples to oranges with different tokenizers&lt;/li&gt;
&lt;li&gt;Do math in my head (or a spreadsheet)&lt;/li&gt;
&lt;li&gt;Realize the blog post I was referencing is 6 months out of date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There had to be a better way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx llm-costs &lt;span class="s2"&gt;"Build a REST API in Python"&lt;/span&gt; &lt;span class="nt"&gt;--compare&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This counts your prompt tokens using the actual tokenizer (tiktoken for OpenAI models, character-based estimation for others), then renders a comparison table across all major providers right in your terminal.&lt;/p&gt;

&lt;p&gt;Output looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model                    Input Cost    Output Cost   Total
─────────────────────────────────────────────────────────
deepseek-chat            $0.00003      $0.00008      $0.00011
gemini-flash-2.0         $0.00005      $0.00020      $0.00025
claude-haiku-3-5         $0.00020      $0.00100      $0.00120
gpt-4o-mini              $0.00027      $0.00108      $0.00135
claude-sonnet-4-5        $0.00150      $0.00750      $0.00900
gpt-4o                   $0.00375      $0.01500      $0.01875
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero install&lt;/strong&gt; — works with &lt;code&gt;npx&lt;/code&gt; or &lt;code&gt;npm i -g llm-costs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;17 models, 6 providers&lt;/strong&gt; — Anthropic, OpenAI, Google, DeepSeek, Mistral, Cohere&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-updating prices&lt;/strong&gt; — fetches fresh pricing weekly via GitHub Actions; client checks staleness locally (7-day TTL cache at &lt;code&gt;~/.llm-costs/pricing.json&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch processing&lt;/strong&gt; — pipe a file of prompts, get cost totals: &lt;code&gt;llm-costs batch prompts.txt&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget guard&lt;/strong&gt; — set a cost ceiling for CI/CD: &lt;code&gt;llm-costs guard --max 0.10&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch mode&lt;/strong&gt; — live-refresh as you type your prompt&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP server mode&lt;/strong&gt; — integrate with Claude Desktop or any MCP-compatible tool&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Price changelog&lt;/strong&gt; — track when costs changed: &lt;code&gt;llm-costs changelog --since 30d&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget projections&lt;/strong&gt; — &lt;code&gt;llm-costs budget --requests 10000&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Auto-Updating Prices — The Key Feature
&lt;/h2&gt;

&lt;p&gt;Most LLM pricing tools go stale within weeks. llm-costs solves this with a two-layer approach:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client-side:&lt;/strong&gt; On each run, the CLI checks if your local &lt;code&gt;~/.llm-costs/pricing.json&lt;/code&gt; is older than 7 days. If it is, it fetches fresh data from GitHub in the background (non-blocking, 5s timeout).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-side:&lt;/strong&gt; A GitHub Actions workflow runs every Monday morning, fetches prices from LiteLLM's aggregate JSON (which tracks provider pricing), diffs the result, and opens a PR if anything changed — including a markdown table showing exactly what went up or down.&lt;/p&gt;

&lt;p&gt;This means the package is always reasonably fresh, and the repo stays transparent about price changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# One-shot, no install:&lt;/span&gt;
npx llm-costs &lt;span class="s2"&gt;"your prompt here"&lt;/span&gt;

&lt;span class="c"&gt;# Or install globally:&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; llm-costs

&lt;span class="c"&gt;# Compare across all models:&lt;/span&gt;
npx llm-costs &lt;span class="s2"&gt;"your prompt"&lt;/span&gt; &lt;span class="nt"&gt;--compare&lt;/span&gt;

&lt;span class="c"&gt;# Check a specific model:&lt;/span&gt;
npx llm-costs &lt;span class="s2"&gt;"your prompt"&lt;/span&gt; &lt;span class="nt"&gt;--model&lt;/span&gt; claude-sonnet-4-5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Open Source?
&lt;/h2&gt;

&lt;p&gt;LLM pricing is genuinely confusing and changes frequently. I wanted something the community could maintain together — PRs to add new models, fix prices, or add providers are very welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/followtayeeb/llm-costs" rel="noopener noreferrer"&gt;https://github.com/followtayeeb/llm-costs&lt;/a&gt; ⭐ (stars appreciated!)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/llm-costs" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/llm-costs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Would love feedback in the comments — what models or features are you missing?&lt;/p&gt;

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