Azure AI URL Builder (config/azureAi.ts)

omniroute95 · open-sse/config/azureAi.ts · typescript · MIT
integration, ai, infra, tag:url, tag:config

Normalizes Azure AI Foundry base URLs and builds chat and models endpoints. Reuse when wiring Azure OpenAI-compatible clients that accept mixed resource URL shapes.

// Source: https://github.com/ChrisStack95/omniroute95 | License: MIT | Copyright 2026 diegosouzapw
// Provided via justclaw.it.com; keep this notice with the code.
import { stripTrailingSlashes, normalizeBaseUrl } from "../utils/urlSanitize.ts";

export const AZURE_AI_DEFAULT_BASE_URL = "https://example-resource.services.ai.azure.com/openai/v1";

export function normalizeAzureAiBaseUrl(value: string | null | undefined): string {
  const normalized = normalizeBaseUrl(value || AZURE_AI_DEFAULT_BASE_URL);
  if (!normalized) return AZURE_AI_DEFAULT_BASE_URL;

  if (
    normalized.endsWith("/chat/completions") ||
    normalized.endsWith("/responses") ||
    normalized.endsWith("/models")
  ) {
    return normalized.replace(/\/(?:chat\/completions|responses|models)$/i, "");
  }

  if (normaliz

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key