<?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: Sovyte</title>
    <description>The latest articles on DEV Community by Sovyte (@sovyte).</description>
    <link>https://dev.to/sovyte</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%2F3966071%2Fca21eebb-1881-4fd3-89e7-fc796d472453.jpg</url>
      <title>DEV Community: Sovyte</title>
      <link>https://dev.to/sovyte</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sovyte"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sovyte</dc:creator>
      <pubDate>Wed, 08 Jul 2026 15:47:18 +0000</pubDate>
      <link>https://dev.to/sovyte/-142d</link>
      <guid>https://dev.to/sovyte/-142d</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g" class="crayons-story__hidden-navigation-link"&gt;Me, a 13 yr old dev built an LLM cost tracker called TokenShark on my laptop at Hyderabad airport&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/sovyte" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3966071%2Fca21eebb-1881-4fd3-89e7-fc796d472453.jpg" alt="sovyte profile" class="crayons-avatar__image" width="800" height="450"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/sovyte" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Sovyte
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Sovyte
                
              
              &lt;div id="story-author-preview-content-4098624" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/sovyte" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3966071%2Fca21eebb-1881-4fd3-89e7-fc796d472453.jpg" class="crayons-avatar__image" alt="" width="800" height="450"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Sovyte&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 8&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g" id="article-link-4098624"&gt;
          Me, a 13 yr old dev built an LLM cost tracker called TokenShark on my laptop at Hyderabad airport
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/programming"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;programming&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/python"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;python&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/claude"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;claude&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt;&amp;nbsp;reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            4 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Me, a 13 yr old dev built an LLM cost tracker called TokenShark on my laptop at Hyderabad airport</title>
      <dc:creator>Sovyte</dc:creator>
      <pubDate>Wed, 08 Jul 2026 15:46:59 +0000</pubDate>
      <link>https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g</link>
      <guid>https://dev.to/sovyte/me-a-13-yr-old-dev-built-an-llm-cost-tracker-called-tokenshark-on-my-laptop-at-hyderabad-airport-2m2g</guid>
      <description>&lt;h2&gt;
  
  
  I built an LLM cost tracker on my laptop at Hyderabad airport
&lt;/h2&gt;

&lt;p&gt;We had a layover in Hyderabad. Long one. Like six hours. I had my laptop and an idea I'd been sitting on.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;I build stuff with LLMs. Chatbots, summarizers, agents that check if my homework makes sense. But you never know what it costs until the bill comes. You call GPT-4o, it works, you call it again, it works again, you ship it, and then your dad asks about the credit card.&lt;/p&gt;

&lt;p&gt;I wanted cost to show up in real-time. In the terminal. Without changing my code. Two lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tokenshark&lt;/span&gt;
&lt;span class="n"&gt;tokenshark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monitor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every OpenAI or Anthropic call gets intercepted, cost-calculated, and logged. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[TokenShark] OpenAI gpt-4o | 1,247â†‘ 382â†“ | $0.0604 | 340ms | trace_id: req_7a3f
[TokenShark] Anthropic claude-3-5-sonnet | 890â†‘ 1,204â†“ | $0.0891 | 1.2s | user: alice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I called it TokenShark because sharks are cool and tokens cost money.&lt;/p&gt;

&lt;h2&gt;
  
  
  The catch
&lt;/h2&gt;

&lt;p&gt;Hyderabad airport WiFi is that kind that "connects" but doesn't actually work. I couldn't pip install anything. No packages, no testing against real SDKs. I had an architecture doc I wrote weeks ago 459 lines of exactly how this should work. And I had weird knowledge of the OpenAI Python SDK.&lt;/p&gt;

&lt;p&gt;So I typed. For hours.&lt;/p&gt;

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

&lt;p&gt;Eight files, ~1,350 lines.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;proxy.py&lt;/code&gt; patches the actual OpenAI and Anthropic clie&lt;br&gt;
nt classes â€” not module-level shortcuts, the real classes. I remembered from reading the SDK source that their client is instance-based. You do &lt;code&gt;client = OpenAI()&lt;/code&gt; and then &lt;code&gt;client.chat.completions.create(...)&lt;/code&gt;. So patching &lt;code&gt;openai.chat.completions.create&lt;/code&gt; only catches module-level calls. Real code uses instances. I had to patch &lt;code&gt;openai.resources.chat.completions.Completions.create&lt;/code&gt; and &lt;code&gt;anthropic.resources.messages.Messages.create&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Streaming was the worst part. OpenAI streams don't include usage by default. You need &lt;code&gt;stream_options={"include_usage": True}&lt;/code&gt; or every chunk has &lt;code&gt;usage=None&lt;/code&gt;. TokenShark auto-injects that. But if some proxy strips it out anyway, it falls back to tiktoken estimation and marks the row as estimated in the database.&lt;/p&gt;

&lt;p&gt;Anthropic streams differently â€” usage is split across &lt;code&gt;message_start&lt;/code&gt; and &lt;code&gt;message_delta&lt;/code&gt; events. I had to assemble the full picture from partial data.&lt;/p&gt;

&lt;p&gt;Cached tokens: OpenAI nests them at &lt;code&gt;usage.prompt_tokens_details.cached_tokens&lt;/code&gt;, but some older responses have a flat &lt;code&gt;usage.cached_tokens&lt;/code&gt;. I check both. Anthropic has &lt;code&gt;cache_creation_input_tokens&lt;/code&gt; and &lt;code&gt;cache_read_input_tokens&lt;/code&gt; as flat attributes. Got all this from memory and a few web searches that squeezed through the spotty airport WiFi.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tracker.py&lt;/code&gt; has the cost calculation, SQLite schema, and database writes. Every call gets logged with provider, model, token counts, cost in dollars, latency, custom tags, whether the cost was estimated or exact, and error messages if it failed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config.py&lt;/code&gt; loads &lt;code&gt;tokenshark.yaml&lt;/code&gt;, merges with defaults, checks for accidentally-committed API keys at every nesting level (not just top-level), and resolves Slack webhooks from env vars. I caught a real bug here â€” my first draft used &lt;code&gt;dict(_DEFAULT_CONFIG)&lt;/code&gt; which is a shallow copy, so mutating nested sections corrupted the module-level default. Fixed with &lt;code&gt;copy.deepcopy()&lt;/code&gt;. Felt pretty smart about that one.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;exceptions.py&lt;/code&gt;, &lt;code&gt;__init__.py&lt;/code&gt;, &lt;code&gt;pyproject.toml&lt;/code&gt; â€” standard stuff. I made &lt;code&gt;openai&lt;/code&gt; and &lt;code&gt;anthropic&lt;/code&gt; optional extras so you don't have to install both if you only use one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Testing with fake SDKs
&lt;/h2&gt;

&lt;p&gt;Couldn't test against real packages. No internet, no pip. So I built fake OpenAI and Anthropic SDKs. Faithful replicas of the real class structures with realistic streaming behavior.&lt;/p&gt;

&lt;p&gt;My fake OpenAI sends chunks where only the final one has usage data (and only if &lt;code&gt;stream_options&lt;/code&gt; was set). My fake Anthropic sends &lt;code&gt;message_start&lt;/code&gt; and &lt;code&gt;message_delta&lt;/code&gt; events with split usage. Tested sync and async clients, streaming and non-streaming, errors, Ollama routing, double &lt;code&gt;monitor()&lt;/code&gt; calls, config merging, dangerous key detection â€” everything.&lt;/p&gt;

&lt;p&gt;Hand-verified the cost math. Fake Claude call with 200 cache-read tokens, 80 cache-creation tokens, 30 output tokens at placeholder rates: &lt;code&gt;(200*3 + 80*15)/1e6 + 30*0.75/1e6 = $0.0018225&lt;/code&gt;. Matched exactly what my code logged to SQLite.&lt;/p&gt;

&lt;p&gt;I was sitting in a plastic airport chair at 2 AM running SQLite queries on my laptop. This is my life.&lt;/p&gt;
&lt;h2&gt;
  
  
  What's left
&lt;/h2&gt;

&lt;p&gt;About 60% through Day 2. Still need: CLI tool, web dashboard, Slack alerts, real tests against actual SDKs, verified pricing (some are placeholders right now), more providers.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why I'm sharing this
&lt;/h2&gt;

&lt;p&gt;Not trying to be a prodigy. Just a kid who likes building things and got stuck at an airport with an idea and too much energy.&lt;/p&gt;

&lt;p&gt;But LLM costs are invisible until they hurt. Making them visible in real-time with zero friction feels like something every developer should have.&lt;/p&gt;

&lt;p&gt;If you've ever been surprised by an LLM bill, maybe give it a look. Or star it. Or tell me why my architecture is wrong. All good outcomes.&lt;br&gt;
&lt;/p&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;tokenshark[openai,anthropic]  &lt;span class="c"&gt;# soon&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or hack on it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/your-org/tokenshark.git
&lt;span class="nb"&gt;cd &lt;/span&gt;tokenshark
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;".[openai,anthropic]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;May your tokens be few and your insights be many.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>python</category>
      <category>claude</category>
    </item>
  </channel>
</rss>
