PROMO$5 FREE CREDITS

    Point the OpenAI Node SDK at Refuseless

    All guides

    You switch the OpenAI Node SDK to Refuseless by setting baseURL to https://api.refuseless.com/v1 and apiKey to a Refuseless key. The option name is camelCase. Python's is base_url. Mixing them up is the usual first bug: the SDK ignores the misspelled field and calls OpenAI, or it calls us without a key. Chat completions keep the same object shape.

    Install and call

    Install openai from npm if you do not have it. Put the key in REFUSELESS_API_KEY. Use a model id from the lineup. The sample uses glm-5.3-refuseless. Replace it when the models page shows another id for that checkpoint.

    Node
    import OpenAI from "openai";
    
    const client = new OpenAI({
      apiKey: process.env.REFUSELESS_API_KEY,
      baseURL: "https://api.refuseless.com/v1",
    });
    
    const response = await client.chat.completions.create({
      model: "glm-5.3-refuseless",
      messages: [
        { role: "user", content: "Summarize this function in one paragraph." },
      ],
    });
    
    console.log(response.choices[0].message.content);

    The base URL includes /v1

    Pass https://api.refuseless.com/v1, not the bare origin and not a full path to /chat/completions. The SDK adds the method path. A doubled /v1/v1 is a 404, and the body will tell you the path was unknown. ESM is what the sample uses. In CommonJS, const OpenAI = require("openai") and the same constructor fields.

    Errors worth recognizing

    • 401 "Missing bearer API key" means the header was empty. The env var is unset in this process, or the option was named api_key and ignored.
    • 401 "Invalid API key" means we received a key that is not a Refuseless key.
    • 404 model_not_found means the id string is wrong. List ids with GET /v1/models before you edit the prompt.

    Agents that already speak the OpenAI shape, and want a config block instead of an SDK call, are covered in the docs and in the console examples. This page is only the Node SDK. Retention is zero prompt retention, which does not change the client code.

    Get an API keySee the lineup