diff --git a/src/api/providers/anthropic.ts b/src/api/providers/anthropic.ts index 93804d99c2..67e1425482 100644 --- a/src/api/providers/anthropic.ts +++ b/src/api/providers/anthropic.ts @@ -19,11 +19,13 @@ export class AnthropicHandler implements ApiHandler { @withRetry() async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream { - let budget_tokens = this.options.thinkingBudgetTokens || 0 - const reasoningOn = budget_tokens !== 0 ? true : false const model = this.getModel() let stream: AnthropicStream const modelId = model.id + + let budget_tokens = this.options.thinkingBudgetTokens || 0 + const reasoningOn = modelId.includes("3-7") && budget_tokens !== 0 ? true : false + switch (modelId) { // 'latest' alias does not support cache_control case "claude-3-7-sonnet-20250219": diff --git a/src/api/providers/bedrock.ts b/src/api/providers/bedrock.ts index aee2363fe9..7d2ce21a7f 100644 --- a/src/api/providers/bedrock.ts +++ b/src/api/providers/bedrock.ts @@ -16,11 +16,12 @@ export class AwsBedrockHandler implements ApiHandler { @withRetry() async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream { - let budget_tokens = this.options.thinkingBudgetTokens || 0 - const reasoningOn = budget_tokens !== 0 ? true : false // cross region inference requires prefixing the model id with the region let modelId = await this.getModelId() + let budget_tokens = this.options.thinkingBudgetTokens || 0 + const reasoningOn = modelId.includes("3-7") && budget_tokens !== 0 ? true : false + // Get model info and message indices for caching const model = this.getModel() const userMsgIndices = messages.reduce((acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc), [] as number[]) diff --git a/src/api/providers/vertex.ts b/src/api/providers/vertex.ts index 6ef9824875..2ba064cab7 100644 --- a/src/api/providers/vertex.ts +++ b/src/api/providers/vertex.ts @@ -32,7 +32,7 @@ export class VertexHandler implements ApiHandler { if (modelId.includes("claude")) { let budget_tokens = this.options.thinkingBudgetTokens || 0 - const reasoningOn = budget_tokens !== 0 ? true : false + const reasoningOn = modelId.includes("3-7") && budget_tokens !== 0 ? true : false let stream switch (modelId) {