@@ -516,14 +516,13 @@ func (c *coordinator) buildAgentModels(ctx context.Context) (Model, Model, error
516516 }, nil
517517}
518518
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) {
520520 var opts []anthropic.Option
521521
522− if strings.HasPrefix(apiKey, "Bearer ") {
522+ if isOauth {
523523 // NOTE: Prevent the SDK from picking up the API key from env.
524524 os.Setenv("ANTHROPIC_API_KEY", "")
525−
526− headers["Authorization"] = apiKey
525+ headers["Authorization"] = fmt.Sprintf("Bearer %s", apiKey)
527526 } else if apiKey != "" {
528527 // X-Api-Key header
529528 opts = append(opts, anthropic.WithAPIKey(apiKey))
@@ -541,7 +540,6 @@ func (c *coordinator) buildAnthropicProvider(baseURL, apiKey string, headers map
541540 httpClient := log.NewHTTPClient()
542541 opts = append(opts, anthropic.WithHTTPClient(httpClient))
543542 }
544−
545543 return anthropic.New(opts...)
546544}
547545
@@ -722,7 +720,7 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
722720 case openai.Name:
723721 return c.buildOpenaiProvider(baseURL, apiKey, headers)
724722 case anthropic.Name:
725− return c.buildAnthropicProvider(baseURL, apiKey, headers)
723+ return c.buildAnthropicProvider(baseURL, apiKey, headers, providerCfg.OAuthToken != nil)
726724 case openrouter.Name:
727725 return c.buildOpenrouterProvider(baseURL, apiKey, headers)
728726 case azure.Name: