@@ -516,14 +516,13 @@ func (c *coordinator) buildAgentModels(ctx context.Context) (Model, Model, error
519−func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map[string]string) (fantasy.Provider, error) {
519+func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map[string]string, isOauth bool) (fantasy.Provider, error) {
520 var opts []anthropic.Option
520 var opts []anthropic.Option
522− if strings.HasPrefix(apiKey, "Bearer ") {
522+ if isOauth {
523 // NOTE: Prevent the SDK from picking up the API key from env.
523 // NOTE: Prevent the SDK from picking up the API key from env.
524 os.Setenv("ANTHROPIC_API_KEY", "")
524 os.Setenv("ANTHROPIC_API_KEY", "")
526− headers["Authorization"] = apiKey
525+ headers["Authorization"] = fmt.Sprintf("Bearer %s", apiKey)
527 } else if apiKey != "" {
526 } else if apiKey != "" {
528 // X-Api-Key header
527 // X-Api-Key header
529 opts = append(opts, anthropic.WithAPIKey(apiKey))
528 opts = append(opts, anthropic.WithAPIKey(apiKey))
@@ -541,7 +540,6 @@ func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map
541 httpClient := log.NewHTTPClient()
540 httpClient := log.NewHTTPClient()
542 opts = append(opts, anthropic.WithHTTPClient(httpClient))
541 opts = append(opts, anthropic.WithHTTPClient(httpClient))
545 return anthropic.New(opts...)
543 return anthropic.New(opts...)
@@ -722,7 +720,7 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
722 case openai.Name:
720 case openai.Name:
723 return c.buildOpenaiProvider(baseURL, apiKey, headers)
721 return c.buildOpenaiProvider(baseURL, apiKey, headers)
724 case anthropic.Name:
722 case anthropic.Name:
725− return c.buildAnthropicProvider(baseURL, apiKey, headers)
723+ return c.buildAnthropicProvider(baseURL, apiKey, headers, providerCfg.OAuthToken != nil)
726 case openrouter.Name:
724 case openrouter.Name:
727 return c.buildOpenrouterProvider(baseURL, apiKey, headers)
725 return c.buildOpenrouterProvider(baseURL, apiKey, headers)
728 case azure.Name:
726 case azure.Name: