Module exposing: resolveAzureOpenAiBaseUrl, appendAzureApiVersion
// Source: https://github.com/can1357/oh-my-pi | License: MIT | Copyright 2025 Mario Zechner
// Provided via justclaw.it.com; keep this notice with the code.
import type { Model } from "@oh-my-pi/pi-ai";
import { $env } from "@oh-my-pi/pi-utils";
const DEFAULT_AZURE_API_VERSION = "v1";
/** Azure OpenAI base URL for compaction requests: env override, resource name, then the model's baseUrl. */
export function resolveAzureOpenAiBaseUrl(model: Model): string {
const baseUrl = $env.AZURE_OPENAI_BASE_URL?.trim() || undefined;
const resourceName = $env.AZURE_OPENAI_RESOURCE_NAME;
const resolvedBaseUrl =
baseUrl ?? (resourceName ? `https://${resourceName}.openai.azure.com/openai/v1` : undefined) ?? model.baseUrl;
if (!resolvedBaseUrl) {
throw new Error(
"Azure OpenAI base URL is requ
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key