<?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: Emmanuel Ekunsumi</title>
    <description>The latest articles on DEV Community by Emmanuel Ekunsumi (@tokoscope).</description>
    <link>https://dev.to/tokoscope</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%2F4007954%2Fa12c85dc-2158-4a81-8cdf-5e551b7ddb4c.jpeg</url>
      <title>DEV Community: Emmanuel Ekunsumi</title>
      <link>https://dev.to/tokoscope</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tokoscope"/>
    <language>en</language>
    <item>
      <title>GLM 5.2 Has a 1M Token Context Window. Here's What That Does to Your API Bill.</title>
      <dc:creator>Emmanuel Ekunsumi</dc:creator>
      <pubDate>Tue, 30 Jun 2026 02:53:59 +0000</pubDate>
      <link>https://dev.to/tokoscope/glm-52-has-a-1m-token-context-window-heres-what-that-does-to-your-api-bill-2fjp</link>
      <guid>https://dev.to/tokoscope/glm-52-has-a-1m-token-context-window-heres-what-that-does-to-your-api-bill-2fjp</guid>
      <description>&lt;p&gt;Z.ai dropped GLM 5.2 on June 13, 2026, and the benchmarks are hard to ignore.&lt;/p&gt;

&lt;p&gt;It's a 744B-parameter Mixture-of-Experts model with roughly 40B active parameters per token, a 1M-token context window, and MIT-licensed weights. It currently ranks #4 out of 124 models on BenchLM's provisional leaderboard with an overall score of 91/100.&lt;/p&gt;

&lt;p&gt;For open-source AI, this is a landmark moment. Across three long-horizon coding benchmarks — FrontierSWE, PostTrainBench, and SWE-Marathon — GLM-5.2 is the highest-ranked open-source model, and the only open-weight model that ranks alongside Claude Opus 4.8 and GPT-5.5 on that class of work.&lt;/p&gt;

&lt;p&gt;But there's a catch nobody is talking about: &lt;strong&gt;a 1M token context window is also a 1M token cost center.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes GLM 5.2 different
&lt;/h2&gt;

&lt;p&gt;GLM 5.2's new capabilities include a solid 1M-token context that stably sustains long-horizon work, stronger coding capabilities with multiple thinking effort levels to balance performance and latency, and an MIT open-source license with no regional limits.&lt;/p&gt;

&lt;p&gt;The architecture introduces IndexShare, which reuses a single lightweight indexer across every four sparse-attention layers and reduces per-token compute by 2.9x at long context lengths. An improved multi-token-prediction layer raises speculative-decoding acceptance by about 20%.&lt;/p&gt;

&lt;p&gt;The benchmark jumps are significant. Terminal-Bench 2.1 rose from 63.5 to 81.0, SWE-bench Pro from 58.4 to 62.1, FrontierSWE from 30.5 to 74.4, and SWE-Marathon from 1.0 to 13.0.&lt;/p&gt;

&lt;p&gt;It is also roughly ⅙ the cost of a frontier LLM — which makes it extremely attractive for teams watching their API bills.&lt;/p&gt;

&lt;h2&gt;
  
  
  The token cost problem nobody mentions
&lt;/h2&gt;

&lt;p&gt;Here's the thing about 1M token context windows: they're incredibly powerful, and incredibly easy to abuse.&lt;/p&gt;

&lt;p&gt;Most developers who get access to a large context window do the same thing: they start throwing everything into the prompt. Full codebases. Complete conversation histories. Entire document sets. Because they can.&lt;/p&gt;

&lt;p&gt;The result is API calls that cost 10-100x more than they need to. Not because the model is expensive per token — GLM 5.2 is actually quite affordable — but because the &lt;strong&gt;volume of tokens per call explodes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We've seen this pattern play out with every major context window expansion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPT-4's 128K window → teams stopped trimming conversation history&lt;/li&gt;
&lt;li&gt;Claude's 200K window → RAG pipelines started returning 50 chunks instead of 5&lt;/li&gt;
&lt;li&gt;GLM 5.2's 1M window → the temptation to send entire repos on every call&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A 1M token context at $0.10 per 1M input tokens is $0.10 per fully-loaded call. At 10,000 calls per day, that's $1,000 daily just on input tokens — before you've even counted output.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use GLM 5.2 without destroying your budget
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Don't fill the context window because you can
&lt;/h3&gt;

&lt;p&gt;The fact that GLM 5.2 &lt;em&gt;accepts&lt;/em&gt; 1M tokens doesn't mean you should &lt;em&gt;send&lt;/em&gt; 1M tokens. The model's strength is that it maintains quality across long contexts — use that for genuinely long tasks, not as an excuse to stop curating what you send.&lt;/p&gt;

&lt;p&gt;Rule of thumb: send the minimum context needed for the model to complete the task. Then measure whether adding more context actually improves the output.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Track token usage per call
&lt;/h3&gt;

&lt;p&gt;Most teams don't know what their average input token count is. They just make API calls and look at the monthly invoice.&lt;/p&gt;

&lt;p&gt;Before you migrate to GLM 5.2 or any large-context model, instrument your calls to track:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input tokens per request&lt;/li&gt;
&lt;li&gt;Which endpoints are sending the most context&lt;/li&gt;
&lt;li&gt;Whether token count correlates with output quality
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;wrap&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tokoscope&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// wrap your GLM 5.2 client via OpenAI-compatible endpoint&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://open.bigmodel.cn/api/paas/v4/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GLM_API_KEY&lt;/span&gt;
&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TOKOSCOPE_API_KEY&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives you instant visibility into what each call actually costs.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Add semantic caching for repeated queries
&lt;/h3&gt;

&lt;p&gt;GLM 5.2's 1M context is perfect for one-shot complex tasks. But if you're using it for repeated queries — customer support, code review, document Q&amp;amp;A — you're paying for the same context over and over.&lt;/p&gt;

&lt;p&gt;Semantic caching catches near-duplicate requests and serves cached responses without hitting the API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;⚡ Cache hit [semantic (89.3% match)] — saved 14,000 tokens ($1.40)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At 1M context scale, cache hits aren't saving 21 tokens. They're saving thousands.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Use thinking effort levels strategically
&lt;/h3&gt;

&lt;p&gt;GLM 5.2 provides a thinking-effort control, with High and Max levels, to balance reasoning depth against latency and compute.&lt;/p&gt;

&lt;p&gt;Not every task needs Max thinking. A customer support query doesn't need the same reasoning depth as a complex refactoring task. Use High for most tasks, Max only when the problem genuinely requires it.&lt;/p&gt;

&lt;h2&gt;
  
  
  GLM 5.2 vs the field on cost
&lt;/h2&gt;

&lt;p&gt;Here's the honest cost picture for teams considering GLM 5.2:&lt;/p&gt;

&lt;p&gt;GLM 5.2 is roughly ⅙ the cost of a frontier LLM. That's a meaningful advantage — but only if you're disciplined about context length.&lt;/p&gt;

&lt;p&gt;A team sending 10K tokens per call at ⅙ the cost will spend less than a team sending 100K tokens per call at full frontier pricing. The model cost advantage disappears fast if you let context bloat compensate for prompt discipline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bottom line
&lt;/h2&gt;

&lt;p&gt;GLM 5.2 is the most capable open-weight model of 2026. For anyone following security research and long-horizon coding, it's a stark reminder that you can't put all your eggs in one LLM basket.&lt;/p&gt;

&lt;p&gt;But the 1M token context window is a double-edged capability. Used well, it enables genuinely new classes of tasks — full repository understanding, hours-long agentic sessions, complex multi-file refactors. Used carelessly, it's a fast path to an API bill that triples in 60 days.&lt;/p&gt;

&lt;p&gt;Measure what you send. Cache what repeats. Compress what's bloated. The model is powerful — don't let token waste cancel out the cost advantage.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Tracking token usage across GLM 5.2, OpenAI, Anthropic, and Gemini? &lt;a href="https://tokoscope.com" rel="noopener noreferrer"&gt;Tokoscope&lt;/a&gt; wraps any OpenAI-compatible endpoint in two lines of code and gives you full token visibility, automatic compression, and semantic caching.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>llm</category>
      <category>ai</category>
      <category>openai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>How I Cut LLM API Costs by 60% With 2 Lines of Code</title>
      <dc:creator>Emmanuel Ekunsumi</dc:creator>
      <pubDate>Mon, 29 Jun 2026 11:00:09 +0000</pubDate>
      <link>https://dev.to/tokoscope/how-i-cut-llm-api-costs-by-60-with-2-lines-of-code-li2</link>
      <guid>https://dev.to/tokoscope/how-i-cut-llm-api-costs-by-60-with-2-lines-of-code-li2</guid>
      <description>&lt;p&gt;Our OpenAI bill tripled in 60 days.&lt;/p&gt;

&lt;p&gt;User growth was up 40%. Revenue was up. But the API bill was growing 3x faster than everything else.&lt;/p&gt;

&lt;p&gt;I spent a week digging into why. What I found was embarrassing and completely fixable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the data showed
&lt;/h2&gt;

&lt;p&gt;After analyzing thousands of real API calls, the same four patterns kept showing up:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Bloated system prompts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most system prompts accumulate over time. Teams add instructions for edge cases, add clarifications, add reminders and never remove anything. The result: system prompts that say the same thing four different ways.&lt;/p&gt;

&lt;p&gt;Here's a real example before and after:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Before - 89 tokens&lt;/span&gt;
You are a helpful customer support assistant. Please make sure to always
be polite and professional in your responses. It is very important that
you respond to customer questions in a helpful manner. Make sure to note
that you should always try to resolve the customer's issue. Please be
concise but also make sure to be thorough. Always maintain a professional
tone and make sure to be empathetic to the customer's situation.

&lt;span class="gh"&gt;# After — 18 tokens&lt;/span&gt;
You are a polite, professional customer support assistant.
Resolve issues concisely and empathetically.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same model behavior. 80% fewer tokens on every single call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. No semantic caching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Exact match caching catches identical prompts. But users don't ask the same question the same way twice.&lt;/p&gt;

&lt;p&gt;"How do I reset my password?" and "I forgot my password, what do I do?" should return the same cached response. Without semantic caching, both hit the API and cost tokens.&lt;/p&gt;

&lt;p&gt;We were running a customer support bot with hundreds of near-duplicate requests every day. Every one was hitting the API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Stuffed context windows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We defaulted to sending full conversation history on every call. Turns out only the last 3-4 turns actually influenced the output. We were paying for 20 turns of context the model was mostly ignoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Zero visibility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We had no idea which feature was burning the most tokens. No breakdown by endpoint. No cost per feature. Just a monthly invoice.&lt;/p&gt;

&lt;p&gt;Turns out our onboarding flow was costing 10x more per user than our core product and we'd never thought to optimize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: two lines of code
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://tokoscope.com" rel="noopener noreferrer"&gt;Tokoscope&lt;/a&gt; to solve this. It wraps your existing LLM client and handles everything automatically:&lt;/p&gt;

&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;openai&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;wrap&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tokoscope&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// Before&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;// After — that's it&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ts_live_...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// from app.tokoscope.com/settings&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// All your existing calls work unchanged&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gpt-4o&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tokoscope&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;

&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# After
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ts_live_...&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# All your existing calls work unchanged
&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gpt-4o&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works with Anthropic and Gemini too, same pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens automatically
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prompt compression
&lt;/h3&gt;

&lt;p&gt;Every prompt gets scored for waste. High-waste prompts are automatically rewritten to their minimum effective form using Claude Haiku before being tracked.&lt;/p&gt;

&lt;p&gt;Real result from our own testing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Original — 113 tokens&lt;/span&gt;
Please note that it is very important that you make sure to respond to
my question. As an AI, I want you to please make sure that you
understand that I need you to help me. Make sure to note that what I am
asking you is the following question which is important:
What is the capital of France? Please make sure to answer clearly.

&lt;span class="gh"&gt;# Compressed — 8 tokens&lt;/span&gt;
What is the capital of France? Answer concisely.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;90% token reduction. Same answer from the model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semantic caching
&lt;/h3&gt;

&lt;p&gt;Two-layer caching system:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1 — Exact match:&lt;/strong&gt; Hash the prompt. Identical requests return cached responses instantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2 — Semantic match:&lt;/strong&gt; Generate an embedding for the prompt. Compare cosine similarity against cached embeddings. At 85%+ similarity, return the cached response.&lt;/p&gt;

&lt;p&gt;Console output when it fires:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;⚡ Tokoscope cache hit [semantic (89.3% match)] — saved 93 tokens ($0.000049)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"What is the population of Japan?" and "How many people live in Japan?" scored 89.3% similarity and correctly served the cached response. Saved a full API call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost attribution
&lt;/h3&gt;

&lt;p&gt;Every call is logged with token counts, cost, waste score, endpoint, and user ID. The dashboard breaks it down so you can see exactly which feature costs the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;Three techniques, compounding:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technique&lt;/th&gt;
&lt;th&gt;What it catches&lt;/th&gt;
&lt;th&gt;Typical saving&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prompt compression&lt;/td&gt;
&lt;td&gt;All calls&lt;/td&gt;
&lt;td&gt;~30%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exact match caching&lt;/td&gt;
&lt;td&gt;Identical prompts&lt;/td&gt;
&lt;td&gt;~10–15%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Semantic caching&lt;/td&gt;
&lt;td&gt;Similar prompts&lt;/td&gt;
&lt;td&gt;~20–25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;60–70%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These compound because they operate at different layers. Compression reduces the size of every call. Caching eliminates calls entirely. Attribution tells you where to focus first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Per-user tracking
&lt;/h2&gt;

&lt;p&gt;If you're building a multi-tenant app, you can pass a user ID to see token usage per end user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// JavaScript&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ts_live_...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;currentUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;Python&lt;/span&gt;
&lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nx"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ts_live_...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;current_user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Users show up in the dashboard with individual token usage, cost, and waste scores.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;tokoscope
&lt;span class="c"&gt;# or&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;tokoscope
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Free tier monitors up to 500K tokens per month. No credit card required.&lt;/p&gt;

&lt;p&gt;The dashboard is at &lt;a href="https://app.tokoscope.com" rel="noopener noreferrer"&gt;app.tokoscope.com&lt;/a&gt; and you can have it running in under 5 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;The biggest surprise wasn't how much waste there was, it was how invisible it was. Without token-level visibility, you're flying blind. You can't optimize what you can't measure.&lt;/p&gt;

&lt;p&gt;The good news: once you can see it, the fixes are usually simple. Compress the system prompt. Add semantic caching. Trim the context window. Three changes, compounding savings.&lt;/p&gt;

&lt;p&gt;The bad news: most teams find out about token waste the same way we did — when the bill arrives.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you're building with LLMs and your API costs keep growing — try Tokoscope. It's free to start and takes 2 minutes to integrate.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feedback welcome in the comments — especially from anyone who's tried different semantic similarity thresholds or embedding models for caching.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>llm</category>
      <category>openai</category>
      <category>python</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
