October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Node.js: Send Chat Completions to Three Models with One Gateway API Key

Use a compatible gateway endpoint and its API key to send the same Chat Completions request to three model IDs from Node.js.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes—you can send the same Chat Completions message to three different models from Node.js using one API key, provided that key belongs to a gateway that offers access to all three. The key authenticates your requests with the gateway; each model value tells it which backend model to use.

What one API key does—and what it does not do

A compatible gateway gives your app a shared API endpoint for models from multiple upstream providers. You configure your client with the gateway’s base URL and API key, then select a model by its identifier in each request. The key is for the gateway account; it should not be confused with an upstream provider’s separate API key.

As an Amazon Associate I earn from qualifying purchases.

OpenRouter documents an OpenAI-compatible endpoint and access to models across providers, with automatic fallback and routing options. Its catalog page reported “500+ models across 80+ providers” when accessed on October 7, 2026; that is a vendor-reported, changeable catalog count, not an independent count. See OpenRouter’s documentation and catalog for current access and model details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up the Node.js client

Install the official OpenAI JavaScript/TypeScript SDK with npm install openai. When using a gateway, configure the SDK with that gateway’s documented base URL and a key issued by that gateway. OpenAI’s own SDK setup uses an OpenAI API key; that does not mean an OpenAI key authenticates requests to a third-party gateway. The SDK README documents the client and Chat Completions request pattern: OpenAI Node.js SDK.

#1 Best Overall
YEELIGHT E1 Smart Home Hub, Matter Controller and Thread Border Router, Wi-Fi and Ethernet Gateway, Works with Apple Home, Alexa, Google Home and SmartThings, Support YEELIGHT Matter Device Only
  • 【Matter Control for Multi-Platform Homes】Connect and manage Matter devices across Apple Home, Alexa, Google Home, and SmartThings from one central hub. Built for smoother cross-platform control and easier smart home expansion. The E1 gateway currently supports Matter-enabled devices from Yeelight. As for other brands, it currently supports only color-capable and adjustable color temperature lights.
  • 【Local Automation with Reliable Offline Response】Run key automations over your local network for faster response and added privacy. Even if your internet connection is interrupted, essential routines can keep working without depending entirely on the cloud.
  • 【Built for Larger Smart Home Setups】Supports up to 150 sub-devices for whole-home automation. Create room-by-room routines, group controls, and multi-device scenes with stable connectivity over Ethernet or Wi-Fi.
  • 【Thread Border Router with LAN API Support】Add Thread-based Matter devices with a built-in Thread Border Router. LAN API support and Home Assistant compatibility give advanced users more flexibility for custom automation and local control.
  • 【Easy Migration for Long-Term Use】Designed for growing smart homes with one-click data migration and dependable device management. A practical choice for users who want to expand their setup without rebuilding automations from scratch.

For an OpenRouter example, set the environment variable in your shell before running the program. Keep the key out of source code and version control.

export OPENROUTER_API_KEY="your-gateway-key"

Send the same messages to three models

This example makes three sequential Chat Completions requests with the same messages array. The model strings are intentionally illustrative, not live model IDs. Replace them with exact identifiers currently listed by your gateway account and available to your region.

Rank #2
Sale
NETGEAR Nighthawk Cable Modem and WiFi 5 Router Combo (C7000)-Discontinued
  • CABLE INTERNET AND WIFI MADE FOR YOUR HOME: This two-in-one cable modem and WiFi router puts every setting in your hands, from your WiFi names and passwords to how your network runs, so it works the way your household needs.
  • APPROVED FOR YOUR PROVIDER AND PLAN: Works with Xfinity internet plans up to 800Mbps and Cox plans up to 500Mbps. Not compatible with Verizon, AT&T, CenturyLink, DirecTV, DISH, or bundled voice plans. ISP activation required after setup.
  • GET THE FULL SPEED OF PLANS UP TO 800 MBPS: DOCSIS 3.0 delivers plenty of speed for HD and 4K streaming, online gaming, and video calls across your home. Actual speeds vary by plan and provider.
  • AC1900 WIFI COVERAGE FOR THE WHOLE HOME: Stay connected in every room with dual-band AC1900 WiFi covering up to 1,800 sq ft and Beamforming+ for stronger signal to mobile devices. Real-world coverage depends on home size, layout, and building materials.
  • WIRED CONNECTIONS FOR YOUR FASTEST DEVICES: Four Gigabit Ethernet ports keep gaming consoles, desktops, and streaming devices hardwired for the lowest latency and the most stable connection in your home.
import OpenAI from "openai";

const apiKey = process.env.OPENROUTER_API_KEY;
if (!apiKey) {
  throw new Error("Set OPENROUTER_API_KEY before running this script.");
}

const client = new OpenAI({
  apiKey,
  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) {
  try {
    const completion = await client.chat.completions.create({
      model,
      messages,
    });
    console.log(model, completion.choices[0]?.message?.content);
  } catch (error) {
    console.error(`Request failed for ${model}:`, error);
  }
}

The OpenRouter quickstart documents this OpenAI-client calling pattern and gateway endpoint. In the usual case, switching the target means changing the model identifier while leaving the surrounding request shape intact. Check the quickstart and current catalog for identifiers and any model-specific routing configuration: OpenRouter quickstart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The loop is sequential, which makes it straightforward to see which model produced each response and which request failed. It does not guarantee that all three calls succeed: a model may be unavailable, unsupported for the account or region, or subject to gateway/provider limits. If you choose to run calls concurrently instead, account for rate limits and handle each result or error independently.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose model IDs and compare the right things

Do not treat the sample identifiers as selectable models. Before running the script, check each exact ID in the gateway’s live catalog and confirm access, pricing, and any routing requirements. A useful comparison should be based on your task rather than a generic ranking:

  • Task quality: test whether each model handles your actual prompts and required output format.
  • Latency: measure response time under your own workload; the gateway may route requests to different providers.
  • Cost: compare current input and output prices for the exact model and billing arrangement.
  • Context and modalities: confirm the model accepts the input length and content types your application sends.
  • Parameters and tools: verify support for options such as tool calling or structured output. Compatibility does not imply that every model supports every parameter.
  • Availability and routing: check geographic eligibility, provider choices, and fallback behavior for the gateway account.

OpenAI’s API reference explicitly notes that parameter support varies by model. That matters even when several models accept the same basic model and messages fields: optional features and response behavior may differ. Consult the Chat Completions API reference and the gateway’s current model details before depending on a parameter across multiple backends.

Rank #4
LTE Wi-Fi Gateway Router (TM-RTL0102) | for TMOBILE | White (Renewed)
  • For T-Mobile only
  • Wi-Fi: Dual-band (2.4GHz & 5GHz) Wi-Fi Standards: 802.11 a/b/g/n/ac
  • Network Support: 4G LTE and 3G LTE Bands: B2, B4, B5, B12, B71, B66 3G/4G Bands: 1, 2, 4, 5, 8
  • Ethernet Ports: Two RJ-45 LAN ports

Why this guide uses Chat Completions

This pattern is specifically for a gateway and models exposing an OpenAI-style Chat Completions interface. OpenAI’s SDK documentation identifies the Responses API as its primary API for interacting with OpenAI models, while describing Chat Completions as the previous standard that remains supported indefinitely. OpenAI recommends considering Responses for new projects centered on OpenAI models; this guide uses Chat Completions because the task is to make compatible requests through a shared gateway interface. These APIs and model backends are not interchangeable in every capability or option. See the SDK documentation for the current SDK guidance.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common failures and fixes

  • Missing-key error: confirm that OPENROUTER_API_KEY is set in the environment running Node.js, and that the key belongs to the configured gateway.
  • Authentication failure: check that the key is valid for the gateway and that the client uses the gateway’s base URL, not an unrelated provider endpoint.
  • Unknown or unavailable model: copy the exact model identifier from the current gateway catalog and confirm that your account and region can use it.
  • Unsupported parameter or feature: remove the optional setting or choose a model that documents support; interface compatibility alone does not ensure feature parity.
  • One request fails in the loop: inspect the gateway’s returned error, availability, limits, and routing settings for that specific model. Catching errors per request lets the remaining iterations proceed.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.