@@ -157,6 +157,15 @@ func (a *anthropicClient) finishReason(reason string) message.FinishReason {
157157 }
158158}
159159
160+func (a *anthropicClient) isThinkingEnabled() bool {
161+ cfg := config.Get()
162+ modelConfig := cfg.Models[config.SelectedModelTypeLarge]
163+ if a.providerOptions.modelType == config.SelectedModelTypeSmall {
164+ modelConfig = cfg.Models[config.SelectedModelTypeSmall]
165+ }
166+ return a.Model().CanReason && modelConfig.Think
167+}
168+
160169func (a *anthropicClient) preparedMessages(messages []anthropic.MessageParam, tools []anthropic.ToolUnionParam) anthropic.MessageNewParams {
161170 model := a.providerOptions.model(a.providerOptions.modelType)
162171 var thinkingParam anthropic.ThinkingConfigParamUnion
@@ -171,7 +180,7 @@ func (a *anthropicClient) preparedMessages(messages []anthropic.MessageParam, to
171180 if modelConfig.MaxTokens > 0 {
172181 maxTokens = modelConfig.MaxTokens
173182 }
174− if a.Model().CanReason && modelConfig.Think {
183+ if a.isThinkingEnabled() {
175184 thinkingParam = anthropic.ThinkingConfigParamOfEnabled(int64(float64(maxTokens) * 0.8))
176185 temperature = anthropic.Float(1)
177186 }
@@ -216,9 +225,14 @@ func (a *anthropicClient) send(ctx context.Context, messages []message.Message,
216225 slog.Debug("Prepared messages", "messages", string(jsonData))
217226 }
218227
228+ var opts []option.RequestOption
229+ if a.isThinkingEnabled() {
230+ opts = append(opts, option.WithHeaderAdd("anthropic-beta", "interleaved-thinking-2025-05-14"))
231+ }
219232 anthropicResponse, err := a.client.Messages.New(
220233 ctx,
221234 preparedMessages,
235+ opts...,
222236 )
223237 // If there is an error we are going to see if we can retry the call
224238 if err != nil {
@@ -268,10 +282,15 @@ func (a *anthropicClient) stream(ctx context.Context, messages []message.Message
268282 slog.Debug("Prepared messages", "messages", string(jsonData))
269283 }
270284
285+ var opts []option.RequestOption
286+ if a.isThinkingEnabled() {
287+ opts = append(opts, option.WithHeaderAdd("anthropic-beta", "interleaved-thinking-2025-05-14"))
288+ }
289+
271290 anthropicStream := a.client.Messages.NewStreaming(
272291 ctx,
273292 preparedMessages,
274− option.WithHeaderAdd("anthropic-beta", "interleaved-thinking-2025-05-14"),
293+ opts...,
275294 )
276295 accumulatedMessage := anthropic.Message{}
277296