Change:
const urlHost = new URL(this.options.openAiBaseUrl).host;
To:
const urlHost = new URL(this.options.openAiBaseUrl ?? "").host;
because the nullish coalescing operator (??) to default to an empty string if this.options.openAiBaseUrl is undefined.
It ensures that the URL constructor always receives a valid string.