spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Fix Microsoft Foundry URL path mode for proxy hosts

Open jewoodev opened this issue 6 months ago • 0 comments

Why: When spring.ai.openai.microsoft-foundry=true is combined with an enterprise proxy base-url, embedding and chat requests miss the /openai/deployments/{deployment} path and the ?api-version=... query, returning 404. The openai-java SDK keeps AzureUrlPathMode.AUTO, which classifies hosts via an Azure-domain whitelist — proxy hosts fall through to NON_AZURE and the SDK skips Azure URL shaping, even when Spring AI has already resolved the provider as MICROSOFT_FOUNDRY.

How: This forwards that decision to the SDK: when the provider is MICROSOFT_FOUNDRY, the client builder is given AzureUrlPathMode.UNIFIED if the base URL ends with /openai/v1, and AzureUrlPathMode.LEGACY otherwise. The path mode is set before credential selection, so the same decision reaches every authentication path. Behavior worked in 1.1.0-M3 and regressed after the SDK migration.

Test: OpenAiSetupTests covers sync/async proxy hosts, the unified endpoint, an explicit Credential injection, and non-Foundry baselines (OpenAI and GitHub Models) that keep AUTO. Verified with ./mvnw package.

Closes #6060

jewoodev avatar May 27 '26 07:05 jewoodev