can1357/oh-my-pi · error · AIError.ConfigurationError
Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL
Error message
Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.
What it means
resolveAzureConfig needs a base URL to reach the Azure OpenAI resource but found none. It checks explicit options (azureBaseUrl, azureResourceName), environment variables (AZURE_OPENAI_BASE_URL, AZURE_OPENAI_RESOURCE_NAME), and finally model.baseUrl. If all are absent it throws a ConfigurationError because an Azure endpoint cannot be constructed.
Source
Thrown at packages/ai/src/providers/azure-openai-responses.ts:300
options?: AzureOpenAIResponsesOptions,
): { baseUrl: string; apiVersion: string } {
const apiVersion = options?.azureApiVersion || $env.AZURE_OPENAI_API_VERSION || DEFAULT_AZURE_API_VERSION;
const baseUrl = options?.azureBaseUrl?.trim() || $env.AZURE_OPENAI_BASE_URL?.trim() || undefined;
const resourceName = options?.azureResourceName || $env.AZURE_OPENAI_RESOURCE_NAME;
let resolvedBaseUrl = baseUrl;
if (!resolvedBaseUrl && resourceName) {
resolvedBaseUrl = `https://${resourceName}.openai.azure.com/openai/v1`;
}
if (!resolvedBaseUrl && model.baseUrl) {
resolvedBaseUrl = model.baseUrl;
}
if (!resolvedBaseUrl) {
throw new AIError.ConfigurationError(
"Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.",
);
}
return {
baseUrl: resolvedBaseUrl.replace(/\/+$/, ""),
apiVersion,
};
}
function modelForAzureEndpoint(
model: Model<"azure-openai-responses">,
baseUrl: string,
): Model<"azure-openai-responses"> {
if (model.supportsComputerUseConfig !== undefined || model.supportsComputerUse !== true) return model;
try {
const url = new URL(baseUrl);
if (View on GitHub (pinned to 9690622007)
Solutions
- Set the AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME environment variable to your Azure OpenAI resource endpoint.
- Pass azureBaseUrl or azureResourceName in the provider options at the call site.
- Set baseUrl on the model object when constructing it programmatically.
- Verify your .env/dotenv loading actually runs before the provider is invoked and the variable names are spelled correctly.
Example fix
// before
await streamAzureOpenAIResponses(model, context); // no endpoint anywhere
// after
process.env.AZURE_OPENAI_RESOURCE_NAME = "my-resource";
await streamAzureOpenAIResponses(model, context, {
azureResourceName: "my-resource",
}); Defensive patterns
Strategy: validation
Validate before calling
const baseUrl = options?.azureBaseUrl ?? process.env.AZURE_OPENAI_BASE_URL ??
(options?.azureResourceName ?? process.env.AZURE_OPENAI_RESOURCE_NAME
? `https://${options?.azureResourceName ?? process.env.AZURE_OPENAI_RESOURCE_NAME}.openai.azure.com`
: model.baseUrl);
if (!baseUrl) throw new Error("Azure OpenAI base URL must be configured before calling the provider."); Type guard
null
Try / catch
try {
await streamAzureOpenAIResponses(model, ctx, options);
} catch (err) {
if (err instanceof AIError.ConfigurationError && err.message.includes("base URL is required")) {
// surface a config setup message to the user
} else throw err;
} Prevention
- Load and validate Azure env vars at application startup, not at first API call.
- Keep a checked-in .env.example listing AZURE_OPENAI_BASE_URL / AZURE_OPENAI_RESOURCE_NAME.
- Prefer explicit options.azureResourceName in embedders over implicit env reliance.
When it happens
Trigger: Calling any streaming/completion function against an azure-openai-responses model when neither AZURE_OPENAI_BASE_URL nor AZURE_OPENAI_RESOURCE_NAME is set in the environment, no azureBaseUrl/azureResourceName option is passed, and the model object carries no baseUrl.
Common situations: Deploying to CI or a fresh machine where the .env file is not loaded; forgetting to configure the resource name after switching from vanilla OpenAI; SDK embedding where options were previously supplied by a wrapper that was removed; typo'd env var names.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL
- OpenAI explicit prompt caching is unsupported for ${model.pr
- Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY e
- CoreWeave Serverless Inference requires OpenAI-Project. Set
- An OpenAI API credential is required for file uploads
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/1c26b58e9c566510.
Report an issue: GitHub.