<?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: AIProfitHub</title>
    <description>The latest articles on DEV Community by AIProfitHub (@aiprofithub).</description>
    <link>https://dev.to/aiprofithub</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%2F3936032%2Fd7ed236c-d75c-42bc-8d3a-df313e7e9f20.png</url>
      <title>DEV Community: AIProfitHub</title>
      <link>https://dev.to/aiprofithub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aiprofithub"/>
    <language>en</language>
    <item>
      <title>I built a free JavaScript SDK to track AI API usage and cost</title>
      <dc:creator>AIProfitHub</dc:creator>
      <pubDate>Sun, 17 May 2026 09:57:19 +0000</pubDate>
      <link>https://dev.to/aiprofithub/i-built-a-free-javascript-sdk-to-track-ai-api-usage-and-cost-293h</link>
      <guid>https://dev.to/aiprofithub/i-built-a-free-javascript-sdk-to-track-ai-api-usage-and-cost-293h</guid>
      <description>&lt;p&gt;I’ve been building AIProfitHub, a tool for tracking AI API usage and cost across AI products.&lt;/p&gt;

&lt;p&gt;One problem I kept seeing: teams ship AI features fast, but they often don’t know which feature, customer, user, or model is creating the cost.&lt;/p&gt;

&lt;p&gt;So I published a small JavaScript SDK to make usage tracking easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Track AI usage events&lt;/li&gt;
&lt;li&gt;Attribute cost by user, team, feature, customer, and model&lt;/li&gt;
&lt;li&gt;Prepare data for budget alerts and cost analysis&lt;/li&gt;
&lt;li&gt;Works with OpenAI, Anthropic, and LangChain-style wrappers&lt;/li&gt;
&lt;/ul&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;npm &lt;span class="nb"&gt;install &lt;/span&gt;aiprofithub-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;createClient&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="s2"&gt;aiprofithub-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&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;createClient&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;AIPROFITHUB_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&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="nf"&gt;trackUsage&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;openai&lt;/span&gt;&lt;span class="dl"&gt;"&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="s2"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;support-chat&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user_123&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;inputTokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;outputTokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;350&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;costUsd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0042&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;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;GitHub:&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/aiprofithub/aiprofithub-js" rel="noopener noreferrer"&gt;https://github.com/aiprofithub/aiprofithub-js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NPM:&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/aiprofithub-sdk" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/aiprofithub-sdk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’d love feedback from developers building AI products:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are you currently tracking LLM usage, token spend, and cost per feature?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>typescript</category>
      <category>opensource</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
