Integrations / OpenAI Node SDK

ConnectDocumented

Use Badgr with the OpenAI Node SDK

Set baseURL and the key in the official OpenAI client for Node and TypeScript.

The steps follow the tool's documented settings. No tested run is recorded for this page yet.

Why use Badgr for OpenAI Node SDK

Badgr interface
AI API
Where OpenAI Node SDK fits
External SDK
Why Badgr
Compatible Node inference
  • Change baseURL and the key. The rest of your OpenAI client code stays.
  • Billed per request at the rate listed for the model.
  • The same account runs GPU jobs and services when you need them.

What you can do

  • Move an existing Node or TypeScript service to Badgr
  • Serverless functions that call a model
  • Streaming replies to a browser through your own API

Quickstart: TypeScript request

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://aibadgr.com/v1",
  apiKey: process.env.BADGR_API_KEY,
});

const reply = await client.chat.completions.create({
  model: "badgr-auto",
  messages: [{ role: "user", content: "Say hello." }],
});

console.log(reply.choices[0].message.content);

How it works

  1. 1.Your code creates a client with the Badgr baseURL
  2. 2.The SDK sends the request to Badgr
  3. 3.You read the reply from the response object

What you get

  • Chat completions and streamed text

Requirements

  • A Badgr API key, saved as BADGR_API_KEY (get one at /get-api-key)
  • Node.js 18 or newer
  • The openai package

What it costs

  • AI requests are billed per request at the rate listed for the model you choose (see Models). This page does not quote a fixed price.
  • Your application keeps control of how many requests it sends. Use the limits in your own tool to cap usage.

See pricing for how billing works.

Proof

No tested run is recorded for this integration yet. A receipt and example output will be added here after a real run, not before.

Troubleshooting

  • Requests still go to OpenAI

    Check for an OPENAI_BASE_URL variable or a client created elsewhere without baseURL.

  • Top-level await error

    Use an ES module (type: module) or wrap the call in an async function.

  • Key missing in the browser

    Keep the key on the server. Do not ship it in browser code.

Developer reference

Ready to start with OpenAI Node SDK?

Every run or service has a spending limit you set before it starts.