Use the OpenAI Node SDK with a custom API base URL
Keep your application code on the familiar OpenAI JavaScript SDK while pointing requests at the CheapClankers API. This walkthrough uses chat completions; choose a model whose live catalogue entry lists the chat protocol.
Updated
1. Create an API key and choose an available model
Create and verify a CheapClankers developer account, then create an API key in the dashboard. Keep the key in a server-side environment variable; do not put it in browser JavaScript or commit it to source control.
Check the model list shown for your key and choose a model that supports chat completions. Model access, status and rates can change, so use the current catalogue and your key's model list instead of copying a model ID from an old example.
export CLANKER_API_KEY="your_key_here"
export CLANKER_MODEL="your_enabled_chat_model_id"2. Install the SDK
Use a current Node.js LTS release supported by the SDK. Install the OpenAI SDK in your Node.js project. The shell commands here use Bash or zsh; in PowerShell set variables with $env:CLANKER_API_KEY = "your_key_here" and $env:CLANKER_MODEL = "your_enabled_chat_model_id".
npm install openai3. List models and send a request
Save the following as setup.mjs and run node setup.mjs from the same shell. The .mjs extension enables import and top-level await without changing package.json. Set the SDK baseURL to the versioned API root. Listing models confirms the IDs your key can access; it does not guarantee current availability or protocol support.
With a valid chat model and sufficient credit, expect a printed model ID list followed by a short greeting. Replace the placeholder model before running the example. Check the request in dashboard usage history to confirm its charge.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.CLANKER_API_KEY,
baseURL: "https://api.cheapclankers.com/v1",
});
const models = await client.models.list();
console.log(models.data.map((model) => model.id));
const result = await client.chat.completions.create({
model: process.env.CLANKER_MODEL,
messages: [{ role: "user", content: "Say hello in one sentence." }],
max_tokens: 128,
});
console.log(result.choices[0]?.message.content);- The key must have access to the selected model.
- The selected model must list chat support; a model may support a different protocol instead.
- Usage is charged against prepaid USD credit at that model's published input and output rates.
If the request fails
Check that the key is active, the model ID is returned by your key's model list, and the model supports chat. A 401 usually means the key is missing or invalid; a 403 can mean key access is restricted; a 404 can mean the model or protocol is unavailable. Check available wallet credit if the API reports insufficient credit.
If a request times out or returns a server error, check its request ID and usage history before retrying. Do not assume an interrupted request was free.
Official tool documentation
These examples describe the endpoint configuration. Review current SDK or tool requirements before installing; live inference and tool support depend on the selected model.
Next steps
Live model catalogue · Published rates and credit packs · API documentation
More tutorials: Use an OpenAI-compatible API in a Next.js Route Handler · Add CheapClankers as a LibreChat custom endpoint · Use the OpenAI Python SDK with a custom API base URL · Configure Claude Code to use the CheapClankers API · Codex CLI setup
New to the service? Create a developer account and review the current model access and rates before adding credit.