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: