← Back to PRs

#18002: fix: add Azure AI Foundry URL support for custom providers

by MisterGuy420 open 2026-02-16 11:18 View on GitHub →
commands size: XS trusted-contributor
## 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