Focused integration answer · Python and JavaScript

How to set a custom base URL in the OpenAI SDK

Configure an existing SDK to send requests to Primordial AI, discover a live model ID, run a minimal smoke test, and verify the compatibility boundary before production use.

Updated 2026-08-24Python: base_urlJavaScript: baseURLServer-side keys only

Direct answer

Set the SDK base URL to https://www.primoraihub.com/v1. In Python the constructor option is base_url; in JavaScript it is baseURL. Keep the API key on your server and select a model ID returned by GET /v1/models.

Base URLhttps://www.primoraihub.com/v1
Python optionbase_url
JavaScript optionbaseURL
Model discoveryGET https://www.primoraihub.com/v1/models
AuthenticationBearer token supplied by the SDK from your server-side API key

The official OpenAI SDK documentation covers installation and the standard client. The endpoint and compatibility instructions on this page describe Primordial AI, not an OpenAI endorsement of a third-party service.

Python: use base_url

Install the official Python package, keep the Primordial API key in an environment variable, then initialize one client:

pip install openai

export PRIMORDIAL_API_KEY="YOUR_PRIMORDIAL_API_KEY"
export PRIMORDIAL_MODEL_ID="MODEL_ID_FROM_V1_MODELS"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["PRIMORDIAL_API_KEY"],
    base_url="https://www.primoraihub.com/v1",
)

configured_id = os.environ["PRIMORDIAL_MODEL_ID"]
models = client.models.list()
available_ids = {model.id for model in models.data}
if configured_id not in available_ids:
    raise RuntimeError(f"Configured model is unavailable: {configured_id}")

response = client.chat.completions.create(
    model=configured_id,
    messages=[{"role": "user", "content": "Reply with exactly: connected"}],
)

print(response.choices[0].message.content)

JavaScript: use baseURL

Use the JavaScript client in a server-side runtime. Do not place a privileged API key in browser-delivered code.

npm install openai

export PRIMORDIAL_API_KEY="YOUR_PRIMORDIAL_API_KEY"
export PRIMORDIAL_MODEL_ID="MODEL_ID_FROM_V1_MODELS"
import OpenAI from "openai";

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

const models = await client.models.list();
const configuredId = process.env.PRIMORDIAL_MODEL_ID;
const availableIds = new Set(models.data.map((model) => model.id));
if (!configuredId || !availableIds.has(configuredId))
  throw new Error(`Configured model is unavailable: ${configuredId}`);

const response = await client.chat.completions.create({
  model: configuredId,
  messages: [{ role: "user", content: "Reply with exactly: connected" }],
});

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

Run the smallest smoke test first

  1. Verify authentication and routing with GET /v1/models.
  2. Copy one ID from the live response rather than inventing a model name.
  3. Send one short, non-streaming chat request.
  4. Only then test streaming, tools, structured output, images, or other optional features documented for your chosen endpoint.
curl https://www.primoraihub.com/v1/models \
  -H "Authorization: Bearer $PRIMORDIAL_API_KEY"

Common configuration errors

Python and JavaScript use different option names

Python expects base_url. JavaScript expects baseURL. Mixing the two can leave the client pointed at its default endpoint.

The URL is missing /v1

Use the complete base URL shown above. The SDK appends resource paths such as /models or /chat/completions.

The model name was copied from another provider

Model catalogs change. Use an ID from the live /v1/models response, follow the model discovery guide, and confirm endpoint support in the current API documentation.

The API key is in frontend code

A browser bundle is public. Send requests through your own server or another trusted runtime where the key can remain secret. Follow the API key quickstart for creation, storage, authentication testing, and rotation.

An optional parameter is rejected

Remove optional parameters, confirm the minimal request works, then add features one at a time using the documented compatibility surface.

A custom base URL is routing, not a blanket compatibility guarantee

Changing the base URL changes where the SDK sends requests. It does not prove that every OpenAI endpoint, parameter, model, streaming event, tool behavior, or response detail is implemented identically.

For production, verify the exact endpoint and feature you use, handle non-success status codes, log request IDs without secrets, and keep a small regression test for your critical request shape.

Frequently asked questions

What custom base URL should I use?

Use https://www.primoraihub.com/v1.

Is the option named base_url or baseURL?

Use base_url in Python and baseURL in JavaScript.

Should the URL include /v1?

Yes. Include /v1 so SDK resource paths resolve under the documented API version.

How do I choose a model ID?

Call GET /v1/models and use an ID returned by the live endpoint.

Does this make every OpenAI feature compatible?

No. Validate the exact endpoint, parameters, streaming behavior, and response fields your application requires against the current Primordial AI documentation.