From ac0972b48b4f5d6710fa9cae6680683ba18647a7 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 20 Feb 2026 13:44:04 -0300 Subject: [PATCH] fix: use `Authorization` header for MiniMax (#2269) Co-authored-by: Greg Slepak --- internal/agent/coordinator.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/agent/coordinator.go b/internal/agent/coordinator.go index a1fd6ae3dd293cac5ad65079c96bad4acd47c4f9..5acafb993d2d40860ae1ccf3992dea9c3e1b7980 100644 --- a/internal/agent/coordinator.go +++ b/internal/agent/coordinator.go @@ -566,14 +566,19 @@ func (c *coordinator) buildAgentModels(ctx context.Context, isSubAgent bool) (Mo }, nil } -func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map[string]string) (fantasy.Provider, error) { +func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map[string]string, providerID string) (fantasy.Provider, error) { var opts []anthropic.Option - if strings.HasPrefix(apiKey, "Bearer ") { + switch { + case strings.HasPrefix(apiKey, "Bearer "): // NOTE: Prevent the SDK from picking up the API key from env. os.Setenv("ANTHROPIC_API_KEY", "") headers["Authorization"] = apiKey - } else if apiKey != "" { + case providerID == string(catwalk.InferenceProviderMiniMax): + // NOTE: Prevent the SDK from picking up the API key from env. + os.Setenv("ANTHROPIC_API_KEY", "") + headers["Authorization"] = "Bearer " + apiKey + case apiKey != "": // X-Api-Key header opts = append(opts, anthropic.WithAPIKey(apiKey)) } @@ -793,7 +798,7 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con case openai.Name: return c.buildOpenaiProvider(baseURL, apiKey, headers) case anthropic.Name: - return c.buildAnthropicProvider(baseURL, apiKey, headers) + return c.buildAnthropicProvider(baseURL, apiKey, headers, providerCfg.ID) case openrouter.Name: return c.buildOpenrouterProvider(baseURL, apiKey, headers) case vercel.Name: