From 962bc851e36618efcc056e339f0dee87f013f06b Mon Sep 17 00:00:00 2001 From: MahendraTeja95 Date: Thu, 12 Mar 2026 00:02:59 +0530 Subject: [PATCH] fix(openai_compat): support prompt_cache_key for Azure OpenAI endpoints Azure OpenAI (*.openai.azure.com) also supports prompt_cache_key, so extend the allowlist to match Azure endpoints alongside api.openai.com. Co-Authored-By: Claude Opus 4.6 --- pkg/providers/openai_compat/provider.go | 7 ++++--- pkg/providers/openai_compat/provider_test.go | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index aa4fa9e6d..841bd76dc 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -480,8 +480,9 @@ func asFloat(v any) (float64, bool) { // supportsPromptCacheKey reports whether the given API base is known to // support the prompt_cache_key request field. Currently only OpenAI's own -// API supports this. All other OpenAI-compatible providers (Mistral, -// Gemini, DeepSeek, Groq, etc.) reject unknown fields with 422 errors. +// API and Azure OpenAI support this. All other OpenAI-compatible providers +// (Mistral, Gemini, DeepSeek, Groq, etc.) reject unknown fields with 422 errors. func supportsPromptCacheKey(apiBase string) bool { - return strings.Contains(apiBase, "api.openai.com") + return strings.Contains(apiBase, "api.openai.com") || + strings.Contains(apiBase, "openai.azure.com") } diff --git a/pkg/providers/openai_compat/provider_test.go b/pkg/providers/openai_compat/provider_test.go index 5581146fe..6ec1e8bd9 100644 --- a/pkg/providers/openai_compat/provider_test.go +++ b/pkg/providers/openai_compat/provider_test.go @@ -785,6 +785,8 @@ func TestSupportsPromptCacheKey(t *testing.T) { }{ {"https://api.openai.com/v1", true}, {"https://api.openai.com/v1/", true}, + {"https://myresource.openai.azure.com/openai/deployments/gpt-4", true}, + {"https://eastus.openai.azure.com/v1", true}, {"https://api.mistral.ai/v1", false}, {"https://generativelanguage.googleapis.com/v1beta", false}, {"https://api.deepseek.com/v1", false},