Skip to content

Commit 79f80da

Browse files
authored
feat(claude): add configurable, additional fields to request header and body (#675)
1 parent d8be5ee commit 79f80da

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/model/claude/claude.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ func NewChatModel(ctx context.Context, config *Config) (*ChatModel, error) {
117117
opts = append(opts, option.WithHTTPClient(config.HTTPClient))
118118
}
119119

120+
for key, value := range config.AdditionalHeaderFields {
121+
opts = append(opts, option.WithHeaderAdd(key, value))
122+
}
123+
124+
for key, value := range config.AdditionalRequestFields {
125+
opts = append(opts, option.WithJSONSet(key, value))
126+
}
127+
120128
cli = anthropic.NewClient(opts...)
121129
}
122130

@@ -231,6 +239,13 @@ type Config struct {
231239
HTTPClient *http.Client `json:"http_client"`
232240

233241
DisableParallelToolUse *bool `json:"disable_parallel_tool_use"`
242+
243+
// Additional fields to set in the HTTP request header.
244+
AdditionalHeaderFields map[string]string `json:"additional_header_fields"`
245+
246+
// Additional fields to set in the API request.
247+
// The values of the map must be JSON serializable.
248+
AdditionalRequestFields map[string]any `json:"additional_request_fields"`
234249
}
235250

236251
type Thinking struct {

0 commit comments

Comments
 (0)