VanaAPI

← Writing

A base URL for a quieter SDK setup

Wire formatsEN2026-10-28

When you use the OpenAI Node SDK, the client needs to know where to send requests. By default, it sends them to OpenAI’s API. The baseURL setting changes that destination, while keeping the rest of the SDK interface familiar.

This is useful when an API provides an OpenAI-compatible endpoint. Vana API is one such service. Its OpenAI-compatible API is available at https://api.vanaapi.com, and it can route requests to models from several providers. You pay for the tokens you use, with no monthly fee.

§ The basic setup

Start by installing the OpenAI package in your Node.js project:

 1  npm install openai

Then create a client with your Vana API key and base URL:

 1  import OpenAI from "openai";
 2  const client = new OpenAI({

  apiKey: process.env.VANA_API_KEY,

 1    baseURL: "https://api.vanaapi.com/v1",
 2  });

The apiKey identifies your account. The baseURL tells the SDK which server should receive the request. The /v1 path is part of the OpenAI-compatible API path used by the client.

§ Making a request

Once the client is configured, a request looks much like a request sent to OpenAI directly:

 1  const response = await client.chat.completions.create({
 2    model: "GPT-6 Astra",
 3    messages: [

    { role: "user", content: "Summarize this note in one sentence." },

  ],

 1  });
 2  console.log(response.choices[0].message.content);

The important detail is that the model name belongs in the request, not in baseURL. The base URL selects the API service. The model field selects the model that service should use.

§ Keep the key out of your code

API keys should not be written directly into source files, especially when a project is stored in Git or shared with other people. Put the key in an environment variable instead.

For example, your local environment can contain:

 1  VANA_API_KEY=your_vana_api_key

Your application can then read it with process.env.VANA_API_KEY. In production, add the variable through your hosting provider’s secret or environment-variable settings. Do not commit a real key to a repository.

§ Common baseURL mistakes

  • Using the default URL by accident: If you omit baseURL, the SDK sends requests to its default OpenAI endpoint.
  • Leaving out the version path: For Vana API’s OpenAI-compatible interface, use https://api.vanaapi.com/v1 as the base URL.
  • Adding a request path twice: The base URL should identify the API root. Do not set it to a full chat-completions path.
  • Using the wrong key: A Vana API key must be paired with the Vana API base URL.
  • Mixing SDK protocols: Vana API also supports Anthropic Messages and Gemini native protocols, but those integrations use their own clients and request formats. This example is specifically for the OpenAI Node SDK.

§ A useful mental model

Think of the OpenAI client as a small HTTP request builder. The API key provides access, the base URL provides the destination, and the model and messages provide the work to perform. Changing the base URL lets an OpenAI-compatible service fit into an existing application without rewriting every request.

When you are ready to try this setup, create a Vana API account, add your key to the environment, and run the same Node.js code against the Vana API endpoint.