@@ -725,7 +725,7 @@ func (c *coordinator) buildAzureProvider(baseURL, apiKey string, headers map[str
725 return azure.New(opts...)
725 return azure.New(opts...)
728−func (c *coordinator) buildBedrockProvider(headers map[string]string) (fantasy.Provider, error) {
728+func (c *coordinator) buildBedrockProvider(apiKey string, headers map[string]string) (fantasy.Provider, error) {
729 var opts []bedrock.Option
729 var opts []bedrock.Option
730 if c.cfg.Config().Options.Debug {
730 if c.cfg.Config().Options.Debug {
731 httpClient := log.NewHTTPClient()
731 httpClient := log.NewHTTPClient()
@@ -734,9 +734,13 @@ func (c *coordinator) buildBedrockProvider(headers map[string]string) (fantasy.P
734 if len(headers) > 0 {
734 if len(headers) > 0 {
735 opts = append(opts, bedrock.WithHeaders(headers))
735 opts = append(opts, bedrock.WithHeaders(headers))
737− bearerToken := os.Getenv("AWS_BEARER_TOKEN_BEDROCK")
737+ switch {
738− if bearerToken != "" {
738+ case apiKey != "":
739− opts = append(opts, bedrock.WithAPIKey(bearerToken))
739+ opts = append(opts, bedrock.WithAPIKey(apiKey))
740+ case os.Getenv("AWS_BEARER_TOKEN_BEDROCK") != "":
741+ opts = append(opts, bedrock.WithAPIKey(os.Getenv("AWS_BEARER_TOKEN_BEDROCK")))
743+ // Skip, let the SDK do authentication.
741 return bedrock.New(opts...)
745 return bedrock.New(opts...)
@@ -824,7 +828,7 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
824 case azure.Name:
828 case azure.Name:
825 return c.buildAzureProvider(baseURL, apiKey, headers, providerCfg.ExtraParams)
829 return c.buildAzureProvider(baseURL, apiKey, headers, providerCfg.ExtraParams)
826 case bedrock.Name:
830 case bedrock.Name:
827− return c.buildBedrockProvider(headers)
831+ return c.buildBedrockProvider(apiKey, headers)
828 case google.Name:
832 case google.Name:
829 return c.buildGoogleProvider(baseURL, apiKey, headers)
833 return c.buildGoogleProvider(baseURL, apiKey, headers)
830 case "google-vertex":
834 case "google-vertex":