<?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: EdsonFernando</title>
    <description>The latest articles on DEV Community by EdsonFernando (@edsonfernando).</description>
    <link>https://dev.to/edsonfernando</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%2F4114607%2Fccf2a5f3-e3d2-4613-99a0-2df12d566833.png</url>
      <title>DEV Community: EdsonFernando</title>
      <link>https://dev.to/edsonfernando</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/edsonfernando"/>
    <language>en</language>
    <item>
      <title>How We Reduced the Cost of Accessing AI Models by Up to 80%</title>
      <dc:creator>EdsonFernando</dc:creator>
      <pubDate>Tue, 08 Sep 2026 00:43:56 +0000</pubDate>
      <link>https://dev.to/edsonfernando/how-we-reduced-the-cost-of-accessing-ai-models-by-up-to-80-14gn</link>
      <guid>https://dev.to/edsonfernando/how-we-reduced-the-cost-of-accessing-ai-models-by-up-to-80-14gn</guid>
      <description>&lt;p&gt;While developing CodeAPI, we noticed that the official price of an AI API does not always represent the lowest possible cost for accessing a particular model.&lt;/p&gt;

&lt;p&gt;This applies to both open-source and proprietary models. Depending on the source, volume, and purchasing terms, the same model can be available at significantly different prices.&lt;/p&gt;

&lt;p&gt;That led us to build an infrastructure that looks for more competitive sources for each model and makes them available through a single API.&lt;/p&gt;

&lt;p&gt;The goal is not to create new models or modify existing ones. CodeAPI is an access layer for models from different providers, with a unified interface for consuming them.&lt;/p&gt;

&lt;p&gt;One of the things we simplified was pricing.&lt;/p&gt;

&lt;p&gt;With CodeAPI, the price per million tokens is the same for input and output tokens. Users do not need to work with two separate pricing tables:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 million input tokens  = the same rate&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1 million output tokens = the same rate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, if a particular route costs US$0.10 per million tokens:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5 million input tokens  = US$0.50&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;5 million output tokens = US$0.50&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On some routes, this structure allows us to reduce the cost by up to 80% compared with the official reference price.&lt;/p&gt;

&lt;p&gt;Reference price CodeAPI price   Reduction&lt;br&gt;
US$0.50/M tokens    US$0.10/M tokens    80%&lt;br&gt;
US$1.00/M tokens    US$0.20/M tokens    80%&lt;br&gt;
US$2.00/M tokens    US$0.40/M tokens    80%&lt;/p&gt;

&lt;p&gt;For a total consumption of 100 million tokens:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference price: US$100&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;CodeAPI:         US$20&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Difference:      US$80&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These values illustrate the difference in proportion. The actual price depends on the model, the available source, and the route being used. The reduction is not necessarily the same for every model.&lt;/p&gt;

&lt;p&gt;The infrastructure supports both open-source and proprietary models. Since the API follows an OpenAI-compatible format, it can be used with applications and tools that already support this standard.&lt;/p&gt;

&lt;p&gt;We have also been able to use it with clients such as Claude Code, while keeping the same general access and usage-based billing model.&lt;/p&gt;

&lt;p&gt;A basic integration using the OpenAI SDK looks like this:&lt;/p&gt;

&lt;p&gt;python&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;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="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="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.codeapi.pro/v1&lt;/span&gt;&lt;span class="sh"&gt;"&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;YOUR_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&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;model-name&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="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;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For projects that already use this standard, integration generally involves changing the base_url, API key, and model name.&lt;/p&gt;

&lt;p&gt;We are still evaluating differences in latency, availability, and rate limits between sources. These factors also matter in production environments; price alone does not determine the best route.&lt;/p&gt;

&lt;p&gt;CodeAPI came out of this effort to find more competitive sources for both open-source and proprietary models, while providing a single and more predictable way to use them.&lt;/p&gt;

&lt;p&gt;More information and API access:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.codeapi.pro" rel="noopener noreferrer"&gt;codeapi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feedback from people already using AI models in production would be especially useful, particularly regarding token volume, cost, latency, and compatibility with tools such as Claude Code.&lt;/p&gt;

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