fix(openai_compat): exclude groq from prompt caching

This commit is contained in:
PixelTux 2026-02-26 22:15:21 +01:00
parent 8a1fb03974
commit 4af8ed1d04

View file

@ -154,9 +154,11 @@ func (p *Provider) Chat(
// The key is typically the agent ID — stable per agent, shared across requests.
// See: https://platform.openai.com/docs/guides/prompt-caching
// Prompt caching is only supported by OpenAI-native endpoints.
// Gemini and other providers reject unknown fields, so skip for non-OpenAI APIs.
// Gemini and Groq reject unknown fields, so skip for non-OpenAI APIs.
if cacheKey, ok := options["prompt_cache_key"].(string); ok && cacheKey != "" {
if !strings.Contains(p.apiBase, "generativelanguage.googleapis.com") {
apiBase := strings.ToLower(p.apiBase)
if !strings.Contains(apiBase, "generativelanguage.googleapis.com") &&
!strings.Contains(apiBase, "groq.com") {
requestBody["prompt_cache_key"] = cacheKey
}
}