fix(providers): add Azure AI Foundry host recognition for prompt caching and native search

This commit is contained in:
Badgerbees 2026-03-21 18:33:10 +07:00
parent 100720bb74
commit eb50a7fab7
2 changed files with 9 additions and 2 deletions

View file

@ -417,7 +417,9 @@ func isNativeSearchHost(apiBase string) bool {
return false
}
host := u.Hostname()
return host == "api.openai.com" || strings.HasSuffix(host, ".openai.azure.com")
return host == "api.openai.com" ||
strings.HasSuffix(host, ".openai.azure.com") ||
strings.HasSuffix(host, ".services.ai.azure.com")
}
// supportsPromptCacheKey reports whether the given API base is known to
@ -430,5 +432,7 @@ func supportsPromptCacheKey(apiBase string) bool {
return false
}
host := u.Hostname()
return host == "api.openai.com" || strings.HasSuffix(host, ".openai.azure.com")
return host == "api.openai.com" ||
strings.HasSuffix(host, ".openai.azure.com") ||
strings.HasSuffix(host, ".services.ai.azure.com")
}

View file

@ -831,6 +831,8 @@ func TestSupportsPromptCacheKey(t *testing.T) {
{"https://api.groq.com/openai/v1", false},
{"http://localhost:11434/v1", false},
{"https://openrouter.ai/api/v1", false},
{"https://myfoundry.eastus.services.ai.azure.com/v1", true},
{"https://myfoundry.services.ai.azure.com", true},
// Edge cases: proxy URLs with openai.com in path should NOT match
{"https://my-proxy.com/api.openai.com/v1", false},
{"https://proxy.example.com/openai.azure.com/v1", false},
@ -900,6 +902,7 @@ func TestIsNativeSearchHost(t *testing.T) {
{"https://api.deepseek.com/v1", false},
{"https://api.groq.com/openai/v1", false},
{"http://localhost:11434/v1", false},
{"https://myfoundry.eastus.services.ai.azure.com/v1", true},
{"", false},
}
for _, tt := range tests {