Install the JavaScript client
Add openai to the server package and commit the lockfile. Use an actively supported Node.js runtime and keep the API client inside server-only modules so bundlers cannot include credentials in frontend output.
CLAUDE API NODE.JS
A Node.js service can call WorldGate's Claude catalogue through the OpenAI JavaScript client. Configure the key on the server, set the WorldGate v1 base URL, and choose a listed Claude identifier. The same pattern works in TypeScript, server routes, workers, and background queues when credentials never reach browser code.
Create an accountAdd openai to the server package and commit the lockfile. Use an actively supported Node.js runtime and keep the API client inside server-only modules so bundlers cannot include credentials in frontend output.
Read WORLDGATE_API_KEY from process.env and stop application startup when it is empty. Do not silently substitute a development key, echo it in an error response, or expose it through a public runtime configuration object.
Pass https://worldgateapi.com/v1 as baseURL and select a current Claude model identifier. Keep the model in validated server configuration rather than accepting any browser-supplied model string.
When streaming, propagate client cancellation to the upstream request, impose an application timeout, and close readers after disconnects. Buffer only what the product needs instead of retaining complete prompts and responses by default.
Retry transient failures with backoff and jitter. Do not retry invalid 400 payloads, authentication failures, or insufficient-balance responses. For jobs with side effects, ensure a repeated model response cannot perform the side effect twice.
Give production APIs, queues, previews, and local development distinct WorldGate keys. Apply a hard cap to autonomous workers when required and use usage records to attribute each Node.js service's token cost.
NODE.JS QUICK START
Use a dedicated project key and never expose it through frontend environment variables.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.WORLDGATE_API_KEY,
baseURL: "https://worldgateapi.com/v1",
});
const response = await client.chat.completions.create({
model: "claude-sonnet-5",
messages: [{ role: "user", content: "Review this TypeScript module." }],
});
console.log(response.choices[0].message.content);METHODOLOGY & SOURCES
Node.js setup reviewed against WorldGate's deployed chat completions surface on July 31, 2026.
COMMON QUESTIONS
Yes. Configure the WorldGate baseURL, WorldGate key, and a Claude model listed in the current catalogue.
No. Keep it in a server-only variable and call WorldGate from a route handler or backend service.
Yes. The OpenAI JavaScript package includes TypeScript support; validate any dynamic model or message input at your application boundary.
Yes. Handle cancellation, timeouts, partial output, and disconnect cleanup explicitly.
Use a dedicated key, configure a hard cap when needed, enable alerts, and restrict retries and maximum output tokens.
Lower model cost. Clearer usage.