Normalizes OCI base URLs, ensuring consistent API paths for chat, responses, and models endpoints.
// Source: https://github.com/diegosouzapw/OmniRoute | 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 OCI_DEFAULT_BASE_URL =
"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1";
export function normalizeOciBaseUrl(value: string | null | undefined): string {
const normalized = normalizeBaseUrl(value || OCI_DEFAULT_BASE_URL);
if (!normalized) return OCI_DEFAULT_BASE_URL;
const stripped = normalized.replace(/\/(?:chat\/completions|responses|models)$/i, "");
if (stripped.endsWith("/openai/v1")) {
return stripped;
}
if (stripped.endsWith("/openai")) {
return `${stripped}/v1`;
}
try {
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key