<?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: 半年游</title>
    <description>The latest articles on DEV Community by 半年游 (@sail).</description>
    <link>https://dev.to/sail</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%2F4102908%2F29ff6643-d5a3-49bc-bf04-bc52a9f5d1ed.jpg</url>
      <title>DEV Community: 半年游</title>
      <link>https://dev.to/sail</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sail"/>
    <language>en</language>
    <item>
      <title>The retry loop in our LLM gateway: what a 5xx does next</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Tue, 24 Nov 2026 05:54:19 +0000</pubDate>
      <link>https://dev.to/sail/when-an-llm-api-returns-5xx-a-practical-guide-to-retries-budgets-and-fallback-53b3</link>
      <guid>https://dev.to/sail/when-an-llm-api-returns-5xx-a-practical-guide-to-retries-budgets-and-fallback-53b3</guid>
      <description>&lt;h1&gt;
  
  
  The retry loop in our LLM gateway: what a 5xx does next
&lt;/h1&gt;

&lt;p&gt;“Retry on 5xx” sounds like a complete rule. In a gateway, it is only one part of the decision. A request can be pinned to one channel, marked non-retryable by an adapter, blocked by a channel-affinity rule, or out of retry budget before its HTTP status is considered.&lt;/p&gt;

&lt;p&gt;I traced this path in the Go relay behind an OpenAI-compatible gateway and ran the status-range tests. The detail that changed my reading of the code was the default retry limit: it is zero. With that value, an ordinary upstream 503 gets one attempt. A status can belong to a retryable range while the request still has no budget to retry.&lt;/p&gt;

&lt;p&gt;This is a report on the checked-in implementation and local tests, not a comparison of provider uptime or rate limits.&lt;/p&gt;

&lt;h2&gt;
  
  
  The counter counts retries, not total requests
&lt;/h2&gt;

&lt;p&gt;The relay initializes its retry counter at zero and loops while the counter is less than or equal to the configured limit. So a limit of zero means one total attempt. A limit of two allows at most three attempts if every failure passes the other checks.&lt;/p&gt;

&lt;p&gt;After a channel returns an error, the relay calls a decision function. In order, it checks affinity rules, special channel-selection errors, an explicit skip-retry marker, the remaining retry budget, whether a specific channel was pinned, and finally the HTTP status range. This ordering explains why reading “500–503 are retryable” from the settings does not by itself predict the number of upstream calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the default status table does
&lt;/h2&gt;

&lt;p&gt;The code's default retry ranges are 100–199, 300–399, 401–407, 409–499, 500–503, 505–523, and 525–599. It leaves out 2xx, 400, 408, 504, and 524. The 504 and 524 exclusions are also explicitly listed as always-skip statuses. Operators can configure the ranges, so these are the checked-in defaults rather than a universal rule for every deployment.&lt;/p&gt;

&lt;p&gt;The checked-in tests exercise the status table directly. These are the default decisions they protect:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;In default retry range?&lt;/th&gt;
&lt;th&gt;Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Successful response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;400&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Invalid request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;401&lt;/td&gt;
&lt;td&gt;Yes, unless another gate skips it&lt;/td&gt;
&lt;td&gt;The status table alone is not the whole decision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;408&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Explicitly excluded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;429&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Rate-limit responses are in 409–499&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500 or 503&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;In 500–503&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;504 or 524&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Explicitly excluded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I also ran a standalone Go model of these ranges with Go 1.25.6 on Windows. Its output matched the checked-in tests. The model deliberately leaves out retry budget, channel pinning, affinity, and error flags, so it only answers whether a status belongs to the generic range policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a 503 can still be a single attempt
&lt;/h2&gt;

&lt;p&gt;The default retry budget is zero, so the remaining-budget gate stops an ordinary HTTP error before the status ranges are consulted. Changing the status ranges alone does not create another call. Both the budget and the error classification have to allow the next attempt.&lt;/p&gt;

&lt;p&gt;For a report of “we enabled 5xx retry but saw one request,” check these in order: the global retry limit, whether the provider adapter marks the error skip-retry, whether the client selected a specific channel, whether an affinity rule suppresses switching, and whether the returned code is in the configured ranges. The channel-selection log then shows whether another eligible channel was chosen.&lt;/p&gt;

&lt;p&gt;A retry limit of two permits up to three attempts, not a guarantee of three. Success ends the loop. A 400 or 504 is outside the default ranges. A pinned channel prevents cross-channel switching. Any explicit skip marker ends the retry path. Each is a separate, observable reason for fewer calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Channel retry and model fallback are different
&lt;/h2&gt;

&lt;p&gt;This relay retry path selects another eligible channel for the same requested model and routing context. It does not silently rewrite the model name. A model fallback is a separate decision, usually made by application logic, and can change output format, tool behavior, context limits, latency, and billing.&lt;/p&gt;

&lt;p&gt;If an application does switch models, make that choice visible in logs and validate the response against the downstream contract. Counting channel retry as model fallback hides what actually happened during an incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we tested
&lt;/h2&gt;

&lt;p&gt;The repository includes status-range tests for cases including 429 and 500 as retryable, and 400, 408, 504, and 524 as non-retryable. I ran the package suite with:&lt;/p&gt;

&lt;p&gt;Command run: go test ./setting/operation_setting. The package tests passed.&lt;/p&gt;

&lt;p&gt;The package test run passed. The table reflects the status-range assertions in that test. The standalone model was run separately as noted above.&lt;/p&gt;

&lt;p&gt;These checks verify local policy code. They do not measure provider availability, observed rate limits, latency, or production retry frequency. A provider comparison would need pinned model IDs, request bodies, retry settings, and a declared concurrency level. Without that setup, status-code examples should not be presented as measured provider behavior.&lt;/p&gt;

&lt;p&gt;When debugging a failed request, follow the same sequence as the code: remaining budget, skip-retry marker, channel pinning or affinity, then status-code range. That is the quickest route from “we got a 503” to “why did this request stop here?”&lt;/p&gt;




&lt;p&gt;The code sample is a simplified executable model of the checked-in status ranges. It is not a provider benchmark.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>programming</category>
    </item>
    <item>
      <title>OpenAI-Compatible Endpoints Explained for Busy Developers</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:23:31 +0000</pubDate>
      <link>https://dev.to/sail/openai-compatible-endpoints-explained-for-busy-developers-5om</link>
      <guid>https://dev.to/sail/openai-compatible-endpoints-explained-for-busy-developers-5om</guid>
      <description>&lt;p&gt;OpenAI-compatible endpoints mean your existing code keeps working: same request shape, same SDK, new base URL. That makes it easy to route requests to GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models without a rewrite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; provides this kind of endpoint with one prepaid key, transparent OpenAI API pricing from $0.01 per million tokens, and support for text, image, voice and video APIs. Change the base URL, keep your SDK, and you are done.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>programming</category>
    </item>
    <item>
      <title>Choosing an AI Gateway: What to Look For Beyond Model Access</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:18:52 +0000</pubDate>
      <link>https://dev.to/sail/choosing-an-ai-gateway-what-to-look-for-beyond-model-access-21gj</link>
      <guid>https://dev.to/sail/choosing-an-ai-gateway-what-to-look-for-beyond-model-access-21gj</guid>
      <description>&lt;p&gt;An AI gateway should be more than a list of models. Look for failover between providers, rate limiting, usage analytics and transparent pricing. The goal is to switch models without rewriting your integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; offers an OpenAI-compatible endpoint for GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models, with per-model pricing from $0.01 per million tokens. Its pricing page publishes every rate, so teams can compare OpenAI API pricing before locking in a provider.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>devtools</category>
    </item>
    <item>
      <title>A Practical Guide to Prepaid AI API Keys</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:18:39 +0000</pubDate>
      <link>https://dev.to/sail/a-practical-guide-to-prepaid-ai-api-keys-4opm</link>
      <guid>https://dev.to/sail/a-practical-guide-to-prepaid-ai-api-keys-4opm</guid>
      <description>&lt;p&gt;Prepaid API keys are a simple way to keep AI costs predictable: top up once, spend per request, and never face a surprise monthly bill. They work well for multi-model projects where usage varies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; is built around this model. A single prepaid key unlocks GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models across text, image, voice and video APIs. You keep your OpenAI SDK, change the base URL, and pay transparent per-model rates starting at $0.01 per million tokens — no subscription, no minimum commitment.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Cut AI API Costs with Transparent Per-Model Rates</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:16:36 +0000</pubDate>
      <link>https://dev.to/sail/cut-ai-api-costs-with-transparent-per-model-rates-473o</link>
      <guid>https://dev.to/sail/cut-ai-api-costs-with-transparent-per-model-rates-473o</guid>
      <description>&lt;p&gt;AI costs can spiral when you do not see per-model rates until the invoice arrives. The fix is a gateway with transparent pricing: published per-model rates, a prepaid balance and no subscription.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; provides exactly that. It aggregates GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models behind one OpenAI-compatible endpoint, with KeyoAPI OpenAI rates starting at $0.01 per million tokens. Use your existing OpenAI SDK, change the base URL, and monitor usage in one dashboard.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Moving from Prototype to Production on a Multi-Model API Gateway</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:15:39 +0000</pubDate>
      <link>https://dev.to/sail/moving-from-prototype-to-production-on-a-multi-model-api-gateway-73l</link>
      <guid>https://dev.to/sail/moving-from-prototype-to-production-on-a-multi-model-api-gateway-73l</guid>
      <description>&lt;p&gt;Prototyping with AI is easy; production is where reliability and cost control bite. A multi-model API gateway gives you failover between providers, rate limiting and usage analytics while keeping a single integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; supports this workflow: one prepaid key for GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models, with transparent OpenAI API pricing from $0.01 per million tokens. Keep your OpenAI SDK, change the base URL, and move from prototype to production without reworking your stack.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>productivity</category>
    </item>
    <item>
      <title>One API Key for GPT, Claude, Gemini and DeepSeek: Why It Works</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:15:11 +0000</pubDate>
      <link>https://dev.to/sail/one-api-key-for-gpt-claude-gemini-and-deepseek-why-it-works-khc</link>
      <guid>https://dev.to/sail/one-api-key-for-gpt-claude-gemini-and-deepseek-why-it-works-khc</guid>
      <description>&lt;p&gt;Integrating multiple AI providers usually means multiple SDKs, keys and invoices. An OpenAI-compatible gateway changes that: one prepaid key, one base URL, and access to GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; gives developers a single endpoint for text, image, voice and video APIs. The OpenAI API pricing on KeyoAPI is published per model and starts at $0.01 per million tokens, so you can switch models without switching infrastructure — just keep your OpenAI SDK and change the base URL.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>cloud</category>
    </item>
    <item>
      <title>How to Compare OpenAI API Pricing Across Model Providers</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:14:56 +0000</pubDate>
      <link>https://dev.to/sail/how-to-compare-openai-api-pricing-across-model-providers-1dga</link>
      <guid>https://dev.to/sail/how-to-compare-openai-api-pricing-across-model-providers-1dga</guid>
      <description>&lt;p&gt;Picking the right model is hard when every provider bills differently. Comparing OpenAI API pricing side by side helps teams forecast costs before they commit to an integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; publishes transparent per-model rates for GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models, all behind one prepaid key. You can keep your OpenAI SDK, change the base URL, and route text, image, voice and video requests through a single endpoint. Rates start at $0.01 per million tokens, with no subscription or minimum commitment — ideal for comparing models in production.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Keep Your OpenAI SDK: Use a Compatible API Gateway and Just Change the Base URL</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Fri, 30 Oct 2026 10:14:12 +0000</pubDate>
      <link>https://dev.to/sail/keep-your-openai-sdk-use-a-compatible-api-gateway-and-just-change-the-base-url-3fcd</link>
      <guid>https://dev.to/sail/keep-your-openai-sdk-use-a-compatible-api-gateway-and-just-change-the-base-url-3fcd</guid>
      <description>&lt;p&gt;Many teams start with OpenAI's SDK and later need other model providers. Instead of rewriting integration code, an OpenAI-compatible API gateway lets you keep your SDK and change only the base URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI&lt;/a&gt; provides a single prepaid key for GPT-class, Claude-class, Gemini-class, DeepSeek and open-source models, covering text, image, voice and video APIs. You can review the KeyoAPI OpenAI rates on its pricing page before you switch, then point your existing SDK at the new endpoint.&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://www.keyoapi.xyz/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_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transparent per-model rates start at $0.01 per million tokens, with no subscription or minimum commitment, so teams can prototype with many models and keep costs predictable.&lt;/p&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>Why Transparent Token Pricing Beats "Contact Us" for Developer Tools</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Mon, 26 Oct 2026 03:04:58 +0000</pubDate>
      <link>https://dev.to/sail/why-transparent-token-pricing-beats-contact-us-for-developer-tools-23j</link>
      <guid>https://dev.to/sail/why-transparent-token-pricing-beats-contact-us-for-developer-tools-23j</guid>
      <description>&lt;p&gt;Developer tools with hidden pricing get skipped. Not because developers are cheap, but because an unknown cost is an unbudgetable cost — and nobody can get a purchase approved for "it depends."&lt;/p&gt;

&lt;h2&gt;
  
  
  What "contact us" signals
&lt;/h2&gt;

&lt;p&gt;To a technical buyer, a missing price page signals one of three things: the price is high enough that they want a sales call first, the price varies enough that they want to size you up, or they haven't figured out their own economics. All three are reasons to keep looking.&lt;/p&gt;

&lt;p&gt;Public pricing signals the opposite: the product has predictable unit economics and enough confidence in them to publish.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a good rate card contains
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Per-unit rates at the smallest meaningful unit.&lt;/strong&gt; For tokens, per million input and output, with cache rates separate. For images, per image at common resolutions. Vague tiers hide the number that matters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Volume thresholds and how they apply.&lt;/strong&gt; If rates drop at volume, say where. If they don't, say that too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's metered and what isn't.&lt;/strong&gt; Retries, failed requests, cached reads, tool calls — ambiguity here is where surprise bills come from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A worked example.&lt;/strong&gt; One realistic request, end to end, with the arithmetic shown. This single item removes more doubt than any FAQ.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it also helps the vendor
&lt;/h2&gt;

&lt;p&gt;Publishing rates forces internal clarity. It surfaces cases where cost structure doesn't match the story. And it makes the self-serve funnel actually self-serve: the developer who can compute their bill doesn't need a call to start.&lt;/p&gt;

&lt;p&gt;Our full per-token table — input, output, cache, across text, image, voice and video — is published here: &lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI [OI] rates&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;No sales call required to find out what it costs.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Prototyping LLM Features for Free: Gift Credits, Small Models and Honest Evals</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Mon, 26 Oct 2026 03:03:23 +0000</pubDate>
      <link>https://dev.to/sail/prototyping-llm-features-for-free-gift-credits-small-models-and-honest-evals-3aeg</link>
      <guid>https://dev.to/sail/prototyping-llm-features-for-free-gift-credits-small-models-and-honest-evals-3aeg</guid>
      <description>&lt;p&gt;You can validate most LLM product ideas before spending meaningful money. The trick is separating "does this feature work" from "does this feature work at production quality."&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 1: Does the feature work at all?
&lt;/h2&gt;

&lt;p&gt;Use free or gift-credit models. You're testing whether the shape of the product makes sense — does the prompt produce plausible output, does the interaction flow feel right, do users understand what to do.&lt;/p&gt;

&lt;p&gt;Quality at this stage doesn't matter much. You're looking for obvious breakage, not production readiness.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 2: Does it hold up?
&lt;/h2&gt;

&lt;p&gt;Run your eval set against two or three candidate models, including one mid-tier paid model. Compare on your own data, not public benchmarks — benchmarks measure someone else's tasks.&lt;/p&gt;

&lt;p&gt;Build a small eval set early: 30-50 examples with expected outputs, scored by exact match where possible and by rubric where not. It takes an afternoon and pays for itself the first time you consider switching models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 3: What does it cost at scale?
&lt;/h2&gt;

&lt;p&gt;Only now do per-token rates matter. Compute cost per successful task: tokens consumed × rate, divided by success rate, including retries. A cheaper model with a 10% higher failure rate can be more expensive per successful outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping prototype and production aligned
&lt;/h2&gt;

&lt;p&gt;The cleanest setup keeps both stages on the same interface. Prototype against a gift-credit model, then swap the model id for a paid one when you promote the feature. No rewrite, no second integration.&lt;/p&gt;

&lt;p&gt;That's the workflow our rate card is built for: gift-credit models for stage one, transparent paid rates from $0.01/M tokens for stage three, all behind one [OI]-compatible key. See &lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;compare [OI] API pricing&lt;/a&gt; for the full list.&lt;/p&gt;

&lt;p&gt;Spending money before stage one is validated is the most common way AI projects die.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rate Limits, Retries and Idempotency: Building Reliable AI Features</title>
      <dc:creator>半年游</dc:creator>
      <pubDate>Mon, 26 Oct 2026 03:01:19 +0000</pubDate>
      <link>https://dev.to/sail/rate-limits-retries-and-idempotency-building-reliable-ai-features-23l9</link>
      <guid>https://dev.to/sail/rate-limits-retries-and-idempotency-building-reliable-ai-features-23l9</guid>
      <description>&lt;p&gt;The first production incident in most AI products is a rate limit. The second is duplicate side effects from retrying after a timeout. Both are avoidable with patterns you already know from ordinary API work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rate limits: plan for two kinds
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Per-minute request caps.&lt;/strong&gt; These throttle bursts. Handle them with a token bucket and a bounded queue, not with unbounded retries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Per-minute token caps.&lt;/strong&gt; Less obvious: a single 100K-token prompt can blow through a token budget that looked generous. Track tokens per minute alongside requests per minute.&lt;/p&gt;

&lt;p&gt;Multi-model gateways add a useful escape hatch: when one model family is saturated, route to another family with spare capacity. That only works if your code treats the model as a parameter — which an [OI]-compatible interface gives you by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retries: only safe when idempotent
&lt;/h2&gt;

&lt;p&gt;Retry aggressively on connection errors and 5xx, never on 4xx. But retries create duplicates unless the operation is idempotent. For anything with side effects — sending an email, writing a record, charging a card — attach an idempotency key and dedupe on the receiving side.&lt;/p&gt;

&lt;p&gt;For pure inference, retries are usually safe. For agentic flows with tool calls, they are not: a retried tool call can execute twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeouts are budgets
&lt;/h2&gt;

&lt;p&gt;Set a wall-clock budget per request, not per attempt. If your budget is 20 seconds, three retries of 10 seconds each is a bug, not resilience. Streaming responses need a separate first-token timeout — waiting 20 seconds to start streaming feels broken even if it eventually succeeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Observability closes the loop
&lt;/h2&gt;

&lt;p&gt;Log retries per endpoint, tokens per minute, and p95 first-token latency. Those three metrics catch nearly every reliability regression before users report it.&lt;/p&gt;

&lt;p&gt;Pricing that publishes input, output and cache rates per model makes capacity planning concrete: &lt;a href="https://www.keyoapi.xyz/openai-api-pricing" rel="noopener noreferrer"&gt;KeyoAPI [OI] rates&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
