{"record":{"id":"1c26b58e9c566510","repo":"can1357/oh-my-pi","slug":"azure-openai-base-url-is-required-set-azure-opena-1c26b5","errorCode":null,"errorMessage":"Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.","messagePattern":"Azure OpenAI base URL is required\\. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model\\.baseUrl\\.","errorType":"exception","errorClass":"AIError.ConfigurationError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/providers/azure-openai-responses.ts","lineNumber":300,"sourceCode":"\toptions?: AzureOpenAIResponsesOptions,\n): { baseUrl: string; apiVersion: string } {\n\tconst apiVersion = options?.azureApiVersion || $env.AZURE_OPENAI_API_VERSION || DEFAULT_AZURE_API_VERSION;\n\n\tconst baseUrl = options?.azureBaseUrl?.trim() || $env.AZURE_OPENAI_BASE_URL?.trim() || undefined;\n\tconst resourceName = options?.azureResourceName || $env.AZURE_OPENAI_RESOURCE_NAME;\n\n\tlet resolvedBaseUrl = baseUrl;\n\n\tif (!resolvedBaseUrl && resourceName) {\n\t\tresolvedBaseUrl = `https://${resourceName}.openai.azure.com/openai/v1`;\n\t}\n\n\tif (!resolvedBaseUrl && model.baseUrl) {\n\t\tresolvedBaseUrl = model.baseUrl;\n\t}\n\n\tif (!resolvedBaseUrl) {\n\t\tthrow new AIError.ConfigurationError(\n\t\t\t\"Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.\",\n\t\t);\n\t}\n\n\treturn {\n\t\tbaseUrl: resolvedBaseUrl.replace(/\\/+$/, \"\"),\n\t\tapiVersion,\n\t};\n}\n\nfunction modelForAzureEndpoint(\n\tmodel: Model<\"azure-openai-responses\">,\n\tbaseUrl: string,\n): Model<\"azure-openai-responses\"> {\n\tif (model.supportsComputerUseConfig !== undefined || model.supportsComputerUse !== true) return model;\n\ttry {\n\t\tconst url = new URL(baseUrl);\n\t\tif (","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/ai/src/providers/azure-openai-responses.ts#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait streamAzureOpenAIResponses(model, context); // no endpoint anywhere\n// after\nprocess.env.AZURE_OPENAI_RESOURCE_NAME = \"my-resource\";\nawait streamAzureOpenAIResponses(model, context, {\n  azureResourceName: \"my-resource\",\n});","handlingStrategy":"validation","validationCode":"const baseUrl = options?.azureBaseUrl ?? process.env.AZURE_OPENAI_BASE_URL ??\n  (options?.azureResourceName ?? process.env.AZURE_OPENAI_RESOURCE_NAME\n    ? `https://${options?.azureResourceName ?? process.env.AZURE_OPENAI_RESOURCE_NAME}.openai.azure.com`\n    : model.baseUrl);\nif (!baseUrl) throw new Error(\"Azure OpenAI base URL must be configured before calling the provider.\");","typeGuard":"null","tryCatchPattern":"try {\n  await streamAzureOpenAIResponses(model, ctx, options);\n} catch (err) {\n  if (err instanceof AIError.ConfigurationError && err.message.includes(\"base URL is required\")) {\n    // surface a config setup message to the user\n  } else throw err;\n}","preventionTips":["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."],"tags":["configuration","azure-openai","missing-env-var","base-url"],"backgroundTag":"missing-env-var","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}