iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
You can send the same Chat Completions request to three different model IDs from Node.js using one API key issued by an OpenAI-compatible gateway. The key authenticates your application with the gateway; each request’s model value tells the gateway which model should handle it. The example below uses OpenRouter’s documented OpenAI-compatible endpoint. You must replace the illustrative model IDs with IDs that are currently available in its catalog.
How one key can reach three models
An OpenAI-compatible gateway provides a common API endpoint for requests to models from multiple upstream providers. Your app sends requests to the gateway using the gateway account’s key. The model identifier selects the backend for each request; it is not a separate API key.
OpenRouter documents a unified OpenAI-compatible endpoint, access to models from multiple providers, and automatic fallback. It reports a catalog of “500+ models across 80+ providers,” a count accessed on October 7, 2026 that can change. See OpenRouter’s quickstart and its model catalog.
Recommended Free Tools
Set up the Node.js client
-
Install the official OpenAI JavaScript/TypeScript SDK in your Node.js project with
npm install openai. -
Create an API key in the gateway account you intend to use. Store it in an environment variable named
OPENROUTER_API_KEY; do not put the secret directly in source code. -
Use the gateway’s documented base URL and key configuration. The OpenAI SDK’s default OpenAI credentials do not authenticate you to a separate gateway. OpenAI documents the SDK installation and client pattern in its JavaScript SDK README; OpenRouter documents its endpoint and client setup in the quickstart.
Rank #2
Send the same Chat Completions request to three model IDs
This example reuses the same user message for each request. The model strings are intentionally illustrative, not guaranteed live IDs: replace them with exact identifiers from the gateway’s current catalog.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: "https://openrouter.ai/api/v1",
});
const messages = [
{ role: "user", content: "Explain what an API gateway does in one sentence." },
];
const models = [
"provider/model-one",
"provider/model-two",
"provider/model-three",
];
for (const model of models) {
const completion = await client.chat.completions.create({ model, messages });
console.log(model, completion.choices[0]?.message?.content);
}
Each iteration makes a separate request. The client, key, endpoint, and message shape stay the same; changing model changes the requested model. The optional chaining prevents a crash if the response has no first choice, but it does not explain why a choice is missing. For a real application, handle request errors and inspect the response according to the gateway and SDK documentation.
Rank #3
Choose and verify the three model IDs
Do not assume a model ID from an old code sample is still available. Before running the example, select three entries in the gateway catalog and confirm their exact IDs, pricing, availability in your region, context limits, supported input and output modalities, and any routing options required. Availability and catalog details can change.
For a useful comparison, send each model the same representative workload, then evaluate the factors that matter to your application:
Rank #4
- Task quality: Check whether each response meets your requirements for accuracy, style, and completeness.
- Latency: Measure elapsed time in your own environment; no general speed ranking follows from using a common API.
- Cost: Check current input and output pricing for each exact model and account for the length of your prompts and responses.
- Context and modality: Verify that the model accepts the input types and context size your request needs.
- Parameters and tools: Confirm support for any options or tool-calling behavior you plan to use. An API-compatible interface does not mean every model accepts every parameter.
- Routing and fallback: Check the gateway’s current routing behavior and preferences when more than one provider can serve a model.
OpenAI’s Chat Completions API reference notes that parameter support varies by model. OpenRouter describes routing preferences in its provider routing documentation. Treat compatibility as a shared request interface, not a promise of identical capabilities or results.
Why this guide uses Chat Completions
This pattern is for a Chat Completions-compatible gateway workflow, especially when an existing application already uses client.chat.completions.create({ model, messages }). It is not a claim that Chat Completions is the preferred API for every new project. The OpenAI SDK documentation calls Responses the primary API for interacting with OpenAI models, while describing Chat Completions as the previous standard for text generation that remains supported indefinitely. Check the SDK documentation when choosing an API for a new OpenAI-specific integration; this article focuses on the compatibility pattern in the assignment.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

