<?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: CheapClankers</title>
    <description>The latest articles on DEV Community by CheapClankers (@cheapclankers).</description>
    <link>https://dev.to/cheapclankers</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%2F4252480%2F75e2d4ba-c381-407a-98f0-bf4826b4e3de.png</url>
      <title>DEV Community: CheapClankers</title>
      <link>https://dev.to/cheapclankers</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cheapclankers"/>
    <language>en</language>
    <item>
      <title>Generate a custom OpenAI API example without putting a key in your browser</title>
      <dc:creator>CheapClankers</dc:creator>
      <pubDate>Wed, 18 Nov 2026 21:01:16 +0000</pubDate>
      <link>https://dev.to/cheapclankers/generate-a-custom-openai-api-example-without-putting-a-key-in-your-browser-1fl1</link>
      <guid>https://dev.to/cheapclankers/generate-a-custom-openai-api-example-without-putting-a-key-in-your-browser-1fl1</guid>
      <description>&lt;p&gt;Disclosure: CheapClankers maintains the tool described here and operates a paid developer API service. This article was prepared with AI. The generated Node.js and Python programs were tested against a local mock API; those checks do not establish production model availability.&lt;/p&gt;

&lt;p&gt;When switching an OpenAI SDK to another compatible endpoint, there are two separate questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Did the client construct the intended HTTP request?&lt;/li&gt;
&lt;li&gt;Does the selected model support that request for this key, right now?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A successful answer to the first question does not establish the second. To make the first request easier to inspect, we published a small &lt;a href="https://macfinn.github.io/cheapclankers-examples/" rel="noopener noreferrer"&gt;browser-only API setup builder&lt;/a&gt;. It generates Node.js, Python and Bash/cURL examples from an API base URL, optional model ID and output limit.&lt;/p&gt;

&lt;p&gt;There is no API key field. The page processes those settings locally and does not send an inference request. You run the generated code separately, with a key in your server-side environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the base URL before the model
&lt;/h2&gt;

&lt;p&gt;For Chat Completions, an SDK normally combines an API base with an operation path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Base:       https://api.example.com/v1
Discovery:  GET  https://api.example.com/v1/models
Generation: POST https://api.example.com/v1/chat/completions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Putting the complete &lt;code&gt;/chat/completions&lt;/code&gt; URL into &lt;code&gt;baseURL&lt;/code&gt; confuses those two layers. The builder rejects complete operation paths, credentials in the URL, query parameters and fragments. It permits HTTPS endpoints, plus HTTP on localhost for a local fixture.&lt;/p&gt;

&lt;p&gt;It also preserves a custom path prefix. A base such as &lt;code&gt;https://example.com/tenant/v1&lt;/code&gt; should produce &lt;code&gt;/tenant/v1/models&lt;/code&gt;, not silently discard &lt;code&gt;/tenant&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This checks URL shape. It does not probe the remote endpoint or prove that another service implements the expected API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make model discovery a separate gate
&lt;/h2&gt;

&lt;p&gt;The generated SDK scripts list models first and stop if the selected ID is absent. Then they send a non-streaming text request with an explicit &lt;code&gt;max_tokens&lt;/code&gt; value. They use a 30-second timeout and disable automatic retries for the first integration check.&lt;/p&gt;

&lt;p&gt;That is still not a universal compatibility test. A model appearing in discovery establishes access to that ID; check Chat Completions support separately. Other protocols, tools, images and model-specific token parameters need their own checks.&lt;/p&gt;

&lt;p&gt;The cURL tab is a manual two-step example: inspect discovery before running the generation command. With no model ID entered, it leaves an explicit model placeholder to replace.&lt;/p&gt;

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

&lt;p&gt;The &lt;a href="https://github.com/MacFinn/cheapclankers-examples/tree/main/docs" rel="noopener noreferrer"&gt;public fixture&lt;/a&gt; runs the generated programs using the real Node.js and Python SDKs against a loopback HTTP server. Its 13 checks cover configuration rejection and six cases per SDK:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A successful request with quotes in the model ID.&lt;/li&gt;
&lt;li&gt;A model ID supplied through the environment.&lt;/li&gt;
&lt;li&gt;A missing API key, with no HTTP request.&lt;/li&gt;
&lt;li&gt;An absent model, with no generation request.&lt;/li&gt;
&lt;li&gt;A 429 during discovery, with no automatic retry.&lt;/li&gt;
&lt;li&gt;A 503 during generation, retaining the request ID in the error output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The assertions check the exact custom-prefix request paths and selected output limit. No paid inference is used. You can reproduce the checks after installing the pinned dependencies in the example repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node --test docs/verify.mjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The SDK fixture does not execute the cURL template, and it does not test streaming or live provider behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep failures deliberate
&lt;/h2&gt;

&lt;p&gt;A timeout does not prove that a server did no work. Before repeating a generation, check usage and any available request status. A small output limit also does not cap every possible charge: input, reasoning and other billed usage depend on the provider and model.&lt;/p&gt;

&lt;p&gt;The builder includes a status-code guide using CheapClankers' documented error meanings. Treat another provider's returned error and documentation as authoritative for that service.&lt;/p&gt;

&lt;p&gt;For our endpoint, the &lt;a href="https://cheapclankers.com/docs" rel="noopener noreferrer"&gt;API setup docs&lt;/a&gt; explain configuration and request IDs, and the &lt;a href="https://cheapclankers.com/models" rel="noopener noreferrer"&gt;model catalogue&lt;/a&gt; lists model IDs, supported protocols, rates and availability. The static builder's source is MIT licensed; the hosted API is a separate paid service.&lt;/p&gt;

&lt;p&gt;The tool is intentionally a request-construction aid. Start with one small, understood request, then test the features your application actually needs.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>python</category>
      <category>api</category>
      <category>opensource</category>
    </item>
    <item>
      <title>A custom OpenAI baseURL in Node.js: check paths before debugging prompts</title>
      <dc:creator>CheapClankers</dc:creator>
      <pubDate>Wed, 18 Nov 2026 18:59:07 +0000</pubDate>
      <link>https://dev.to/cheapclankers/a-custom-openai-baseurl-in-nodejs-check-paths-before-debugging-prompts-1bf4</link>
      <guid>https://dev.to/cheapclankers/a-custom-openai-baseurl-in-nodejs-check-paths-before-debugging-prompts-1bf4</guid>
      <description>&lt;p&gt;Disclosure: this tutorial is published by CheapClankers, an independent developer API service. It uses our endpoint as a concrete example; it is not an OpenAI endorsement or a ChatGPT subscription. Prepared with AI; the companion examples were verified against a local mock API, not production inference.&lt;/p&gt;

&lt;p&gt;When moving a small application to an OpenAI-compatible endpoint, a failed request is often a configuration problem. Before changing your prompt, separate three questions: did the request reach the right path, can the key access the model, and does that model support the operation?&lt;/p&gt;

&lt;p&gt;Here is a small Node.js workflow for answering the first two questions without hiding retries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the SDK the API root
&lt;/h2&gt;

&lt;p&gt;Use Node.js 22 or later and install a known SDK version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install openai@7.60.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Bash or zsh, set a server-side key and an exact model ID that supports chat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLANKER_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your_key_here"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLANKER_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your_enabled_chat_model_id"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In PowerShell, use &lt;code&gt;$env:CLANKER_API_KEY = "your_key_here"&lt;/code&gt; and &lt;code&gt;$env:CLANKER_MODEL = "your_enabled_chat_model_id"&lt;/code&gt; instead. Never ship this private key in frontend JavaScript.&lt;/p&gt;

&lt;p&gt;Save this as &lt;code&gt;check.mjs&lt;/code&gt;. The extension enables &lt;code&gt;import&lt;/code&gt; and top-level &lt;code&gt;await&lt;/code&gt; without changing your project's module settings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"openai"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLANKER_API_KEY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLANKER_MODEL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Set CLANKER_API_KEY and CLANKER_MODEL in this shell."&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.cheapclankers.com/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;maxRetries&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;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30_000&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&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;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;model&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Selected model was not returned for this 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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&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="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;messages&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;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="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Say hello in one sentence."&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;max_tokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;128&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;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="o"&gt;?&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;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;node check.mjs&lt;/code&gt; from the same shell. With a valid model, sufficient credit and an available route, expect a short greeting. This performs a real, metered completion.&lt;/p&gt;

&lt;p&gt;The SDK adds operation paths to &lt;code&gt;baseURL&lt;/code&gt;. In this configuration, model listing goes to &lt;code&gt;/v1/models&lt;/code&gt;, and the completion goes to &lt;code&gt;/v1/chat/completions&lt;/code&gt;. Do not use the full completion URL as the base: it is a resource path, not the API root.&lt;/p&gt;

&lt;h2&gt;
  
  
  A model list is an access check
&lt;/h2&gt;

&lt;p&gt;Finding the ID in the list does not prove that its upstream is online or that it supports every OpenAI operation. Check the model's current protocol and status before using chat completions. A Responses-only model needs a different request shape and endpoint; changing a prompt cannot fix that mismatch.&lt;/p&gt;

&lt;p&gt;A 401 suggests checking credentials. A 403 can indicate a restriction on the key. A 404 can indicate an unavailable model or unsupported protocol. If a request reports insufficient credit, inspect the wallet rather than changing SDK settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retry deliberately
&lt;/h2&gt;

&lt;p&gt;This diagnostic example uses &lt;code&gt;maxRetries: 0&lt;/code&gt;, so one failed SDK operation does not automatically become several attempts. The timeout limits how long the client waits; it does not prove that the server stopped working or that no usage was incurred. Keep the request ID and check dashboard usage before resending an interrupted request.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/MacFinn/cheapclankers-examples" rel="noopener noreferrer"&gt;companion GitHub examples&lt;/a&gt; include complete scripts and a loopback-only mock test harness for both Node.js and Python.&lt;/p&gt;

&lt;p&gt;For a step-by-step configuration walkthrough, see the &lt;a href="https://cheapclankers.com/guides/openai-node-sdk" rel="noopener noreferrer"&gt;OpenAI Node.js SDK setup guide&lt;/a&gt;. The &lt;a href="https://cheapclankers.com/docs" rel="noopener noreferrer"&gt;CheapClankers API documentation&lt;/a&gt; covers account setup and supported protocols. For client behavior beyond this example, use the &lt;a href="https://github.com/openai/openai-node#readme" rel="noopener noreferrer"&gt;official JavaScript SDK documentation&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>api</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
