<?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: Plugsky</title>
    <description>The latest articles on DEV Community by Plugsky (plugsky-ai).</description>
    <link>https://dev.to/plugsky-ai</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%2Forganization%2Fprofile_image%2F16419%2Fa304bc7d-01fe-4b5f-94e6-d016e047c99c.png</url>
      <title>DEV Community: Plugsky</title>
      <link>https://dev.to/plugsky-ai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/plugsky-ai"/>
    <language>en</language>
    <item>
      <title>Migrating an OpenAI SDK app to a flat-rate AI API without rewriting your code</title>
      <dc:creator>Plugsky</dc:creator>
      <pubDate>Tue, 24 Nov 2026 18:52:48 +0000</pubDate>
      <link>https://dev.to/plugsky-ai/migrating-an-openai-sdk-app-to-a-flat-rate-ai-api-without-rewriting-your-code-46i0</link>
      <guid>https://dev.to/plugsky-ai/migrating-an-openai-sdk-app-to-a-flat-rate-ai-api-without-rewriting-your-code-46i0</guid>
      <description>&lt;p&gt;Most OpenAI-compatible migrations fail for a boring reason: the SDK call is easy to change, but the cost model, retries and context handling are not.&lt;/p&gt;

&lt;p&gt;This is the checklist I would use for a small production app that currently pays per token and wants a flat monthly plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Change the base URL, not the SDK
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&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="s2"&gt;"https://api.plugsky.com/v1"&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="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"PLUGSKY_API_KEY"&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="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="s2"&gt;"plugsky-pro"&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="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&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="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your app already uses the OpenAI SDK, this is the whole integration change. Keep the SDK version pinned and run your existing tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Map model names explicitly
&lt;/h2&gt;

&lt;p&gt;Do not let a wildcard map every model. Write a small table in your config:&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="no"&gt;MODEL_MAP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"gpt-4o"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"plugsky-pro"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"gpt-4o-mini"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"plugsky-lite"&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;Then log the requested model and the served model from the response. Compatibility aliases are not the upstream model. If the response exposes &lt;code&gt;model&lt;/code&gt; and &lt;code&gt;served_by&lt;/code&gt;, store both.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Measure the bill you are leaving
&lt;/h2&gt;

&lt;p&gt;Export the last 30 days of input and output tokens. Price them at the per-token rates you actually paid, including retries and failed tool calls. Compare that number with the flat plan.&lt;/p&gt;

&lt;p&gt;A flat plan is not automatically cheaper. It is a different allocation of risk. If your usage is low or spiky, per-token can win.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test the limits that still exist
&lt;/h2&gt;

&lt;p&gt;Ask four questions in writing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is there a monthly token cap?&lt;/li&gt;
&lt;li&gt;Is there a per-token overage?&lt;/li&gt;
&lt;li&gt;What is the concurrency limit?&lt;/li&gt;
&lt;li&gt;What is the RPM limit?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Plugsky Builder ($60) and Scale ($120) have no monthly token cap, no per-token overage and no pay-as-you-go meter. They still publish 10 or 16 concurrent requests, 600 or 1,200 RPM, 256K/512K input and 32K output. Those are the limits your retry logic will hit first.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Run a canary, not a big bang
&lt;/h2&gt;

&lt;p&gt;Send 5–10% of traffic to the new endpoint for a week. Compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;p50 and p95 latency&lt;/li&gt;
&lt;li&gt;error rate by model&lt;/li&gt;
&lt;li&gt;fallback rate&lt;/li&gt;
&lt;li&gt;cost per successful task&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A migration is finished when the error rate and the cost per successful task are both acceptable, not when the first request returns 200.&lt;/p&gt;

&lt;h2&gt;
  
  
  When not to migrate
&lt;/h2&gt;

&lt;p&gt;Do not migrate if you need a model that is not in the catalogue, if your compliance team has not approved the data path, or if your workload is small enough that per-token is cheaper. A flat plan is a tool, not a religion.&lt;/p&gt;

&lt;p&gt;Disclosure: I work on Plugsky. The migration steps apply to any OpenAI-compatible endpoint. The no-cap definition and published limits are at &lt;a href="https://plugsky.com/flat-rate-ai-api" rel="noopener noreferrer"&gt;https://plugsky.com/flat-rate-ai-api&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>openai</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
