DEV Community

CheapClankers
CheapClankers

Posted on Fully Autonomous

Generate a custom OpenAI API example without putting a key in your browser

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.

When switching an OpenAI SDK to another compatible endpoint, there are two separate questions:

  1. Did the client construct the intended HTTP request?
  2. Does the selected model support that request for this key, right now?

A successful answer to the first question does not establish the second. To make the first request easier to inspect, we published a small browser-only API setup builder. It generates Node.js, Python and Bash/cURL examples from an API base URL, optional model ID and output limit.

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.

Check the base URL before the model

For Chat Completions, an SDK normally combines an API base with an operation path:

Base:       https://api.example.com/v1
Discovery:  GET  https://api.example.com/v1/models
Generation: POST https://api.example.com/v1/chat/completions
Enter fullscreen mode Exit fullscreen mode

Putting the complete /chat/completions URL into baseURL 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.

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

This checks URL shape. It does not probe the remote endpoint or prove that another service implements the expected API.

Make model discovery a separate gate

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 max_tokens value. They use a 30-second timeout and disable automatic retries for the first integration check.

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.

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.

What we actually tested

The public fixture 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:

  • A successful request with quotes in the model ID.
  • A model ID supplied through the environment.
  • A missing API key, with no HTTP request.
  • An absent model, with no generation request.
  • A 429 during discovery, with no automatic retry.
  • A 503 during generation, retaining the request ID in the error output.

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:

node --test docs/verify.mjs
Enter fullscreen mode Exit fullscreen mode

The SDK fixture does not execute the cURL template, and it does not test streaming or live provider behavior.

Keep failures deliberate

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.

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.

For our endpoint, the API setup docs explain configuration and request IDs, and the model catalogue lists model IDs, supported protocols, rates and availability. The static builder's source is MIT licensed; the hosted API is a separate paid service.

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

Top comments (0)