#18002: fix: add Azure AI Foundry URL support for custom providers
commands
size: XS
trusted-contributor
Cluster:
Model Authentication Enhancements
## Summary
Fixed the issue where configuring OpenAI models from Azure AI Foundry returns a 400 error. The fix detects Azure AI Foundry URLs (both services.ai.azure.com and openai.azure.com) and transforms them to include the proper deployment path (/openai/deployments/<model-id>) required by Azure's API.
## Changes
- Added isAzureUrl() function to detect Azure AI Foundry and Azure OpenAI URLs
- Added transformAzureUrl() function to transform Azure URLs to include the deployment path
- Updated requestOpenAiVerification() and requestAnthropicVerification() to transform Azure URLs before verification
- Updated applyCustomApiConfig() to store the transformed URL so API calls also work correctly
## Testing
- Build completed successfully
- Code follows existing patterns in onboard-custom.ts
- E2E tests use non-Azure URLs so should continue to pass
Fixes openclaw/openclaw#17992
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds Azure AI Foundry URL support for custom providers by detecting Azure URLs and transforming them to include the required `/openai/deployments/<model-id>` path. The implementation addresses a 400 error when configuring OpenAI models from Azure AI Foundry.
**Key changes:**
- Added `isAzureUrl()` to detect Azure AI Foundry (`*.services.ai.azure.com`) and Azure OpenAI (`*.openai.azure.com`) URLs
- Added `transformAzureUrl()` to append the deployment path to Azure URLs
- Updated verification functions to transform Azure URLs before making API calls
- Updated `applyCustomApiConfig()` to store the transformed URL for subsequent API calls
**Issues found:**
- URL normalization inconsistency: when a URL already contains the deployment path, the function returns the original string instead of the normalized URL, which could cause subtle differences in URL formatting compared to newly transformed URLs
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with one minor logical issue to address
- The implementation correctly addresses the Azure AI Foundry URL transformation requirement and follows the existing code patterns. The URL API is properly used to handle query parameters (addressing a previous review comment). However, there's a URL normalization inconsistency in the early return path that should be fixed to ensure consistent behavior. The fix is straightforward (changing line 48 from `return baseUrl` to `return url.toString()`). The Anthropic verification transformation is intentionally designed to fail (per the added comment), which is correct behavior. The changes are well-tested by the existing E2E tests (which use non-Azure URLs and should continue to pass).
- No files require special attention beyond addressing the logical issue noted in the inline comment
<sub>Last reviewed commit: 7b46b46</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#12059: feat(agents): Add Azure AI Foundry credential support
by lisanyambere · 2026-02-08
81.6%
#16766: fix(model): apply provider baseUrl/headers override to registry-fou...
by dzianisv · 2026-02-15
77.7%
#14475: feat: Add native Azure OpenAI support
by dzianisv · 2026-02-12
77.1%
#4057: fix: sanitize tool call IDs for Azure OpenAI
by wangchuan3533 · 2026-01-29
76.6%
#15197: fix: allow OpenAI auth profiles for OpenAI-compatible providers
by bufordtjustice2918 · 2026-02-13
74.8%
#13079: feat: Add OpenAI-compatible API option to CLI for self-hosted models
by MikeWang0316tw · 2026-02-10
74.4%
#14239: Add Azure OpenAI Completions provider
by KJFromMicromonic · 2026-02-11
74.3%
#10424: feat: Add OVHcloud AI Endpoints as a provider
by eliasto · 2026-02-06
73.9%
#19281: fix: set supportsDeveloperRole false as default for moonshot provider
by MisterGuy420 · 2026-02-17
73.9%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
73.4%