Mintplex-Labs/anything-llm · error · Error
"${azureOpenAiEndpoint}" is not a valid URL. Check your sett
Error message
"${azureOpenAiEndpoint}" is not a valid URL. Check your settings for the Azure OpenAI provider and set a valid endpoint URL. What it means
Thrown by the static `AzureOpenAiLLM.formatBaseUrl` when `new URL(azureOpenAiEndpoint)` raises — i.e. the string is not an absolute, parseable URL. formatBaseUrl normalizes the endpoint by forcing https, setting pathname to /openai/v1, and clearing query/hash; if the input cannot even be parsed as a URL, normalization is impossible and the catch rethrows a descriptive message.
Source
Thrown at server/utils/AiProviders/azureOpenAi/index.js:62
`Initialized. Model "${this.model}" @ ${this.promptWindowLimit()} tokens.\nAPI-Version: ${this.apiVersion}.\nModel Type: ${this.isOTypeModel ? "reasoning" : "default"}`
);
}
/**
* Formats the Azure OpenAI endpoint URL to the correct format.
* @param {string} azureOpenAiEndpoint - The Azure OpenAI endpoint URL.
* @returns {string} The formatted URL.
*/
static formatBaseUrl(azureOpenAiEndpoint) {
try {
const url = new URL(azureOpenAiEndpoint);
url.pathname = "/openai/v1";
url.protocol = "https";
url.search = "";
url.hash = "";
return url.href;
} catch {
throw new Error(
`"${azureOpenAiEndpoint}" is not a valid URL. Check your settings for the Azure OpenAI provider and set a valid endpoint URL.`
);
}
}
#log(text, ...args) {
console.log(`\x1b[32m[AzureOpenAi]\x1b[0m ${text}`, ...args);
}
#appendContext(contextTexts = []) {
if (!contextTexts || !contextTexts.length) return "";
return (
"\nContext:\n" +
contextTexts
.map((text, i) => {
return `[CONTEXT ${i}]:\n${text}\n[END CONTEXT ${i}]\n\n`;
})
.join("")View on GitHub (pinned to 526360e320)
Solutions
- Set AZURE_OPENAI_ENDPOINT to a full URL including scheme: `https://<resource>.openai.azure.com` (no path, no query).
- Trim any trailing whitespace, quotes, or newlines from the value in .env.
- Validate it parses before deploy: `node -e "new URL(process.env.AZURE_OPENAI_ENDPOINT)"`.
- Re-copy the endpoint from the Azure portal > resource > Keys and Endpoint to avoid transcription errors.
Example fix
// before AZURE_OPENAI_ENDPOINT=my-resource.openai.azure.com // after AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com
Defensive patterns
Strategy: validation
Validate before calling
function isValidAzureEndpoint(raw) {
if (typeof raw !== "string" || raw.trim().length === 0) return false;
try {
const u = new URL(raw.trim());
return u.protocol === "https:" && /\.openai\.azure\.com$/.test(u.hostname);
} catch {
return false;
}
}
if (!isValidAzureEndpoint(process.env.AZURE_OPENAI_ENDPOINT)) {
throw new Error("AZURE_OPENAI_ENDPOINT must be a valid https://*.openai.azure.com URL.");
} Type guard
/** @param {string} raw @returns {boolean} */
function isValidHttpsUrl(raw) {
try { return new URL(raw).protocol === "https:"; } catch { return false; }
} Try / catch
try {
const base = AzureOpenAiLLM.formatBaseUrl(process.env.AZURE_OPENAI_ENDPOINT);
} catch (e) {
if (/is not a valid URL/.test(e.message)) {
return { ok: false, reason: "bad-endpoint-url", hint: "Include https:// and the .openai.azure.com host." };
}
throw e;
} Prevention
- Validate the endpoint URL at config-save time, not at first request.
- Always include the https:// scheme in stored values.
- Trim whitespace and strip quotes when reading endpoint env vars.
- Unit-test formatBaseUrl against scheme-less, query-laden, and host-only inputs.
When it happens
Trigger: AZURE_OPENAI_ENDPOINT is truthy but malformed: missing scheme (e.g. `my-resource.openai.azure.com`), has spaces, is a relative path, or contains invalid characters. The constructor calls formatBaseUrl(process.env.AZURE_OPENAI_ENDPOINT), so this surfaces at construction time, after the key guard.
Common situations: User pasted just the hostname without `https://`; copied the endpoint with a trailing path/query that breaks URL parsing; trailing whitespace/newline in the env value; accidental paste of the deployment name instead of the endpoint URL.
Related errors
- No Azure API endpoint was set.
- No Azure API key was set.
- No Anthropic API key was set.
- No ApiPie LLM API key was set.
- No AZURE_OPENAI_MODEL_PREF ENV defined. This must the name o
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/48e95d7ea4925a98.
Report an issue: GitHub.