diff --git a/transformers/request-anthropic.js b/transformers/request-anthropic.js index 1e8573a..7f533ca 100644 --- a/transformers/request-anthropic.js +++ b/transformers/request-anthropic.js @@ -120,23 +120,10 @@ export function transformToAnthropic(openaiRequest) { type: 'enabled', budget_tokens: budgetTokens[reasoningLevel] }; - } - // If request already has thinking field, respect the configuration rule - // Remove it if model config is off/invalid, otherwise override with config - if (openaiRequest.thinking) { - if (reasoningLevel) { - const budgetTokens = { - 'low': 4096, - 'medium': 12288, - 'high': 24576 - }; - - anthropicRequest.thinking = { - type: 'enabled', - budget_tokens: budgetTokens[reasoningLevel] - }; - } - // If reasoningLevel is null (off/invalid), don't add thinking field + } else { + // If reasoning is off or invalid, explicitly remove thinking field + // This ensures any thinking field from the original request is deleted + delete anthropicRequest.thinking; } // Pass through other compatible parameters diff --git a/transformers/request-openai.js b/transformers/request-openai.js index e17c97f..fb95ea1 100644 --- a/transformers/request-openai.js +++ b/transformers/request-openai.js @@ -91,21 +91,15 @@ export function transformToOpenAI(openaiRequest) { // Handle reasoning field based on model configuration const reasoningLevel = getModelReasoning(openaiRequest.model); if (reasoningLevel) { + // Add reasoning field based on model configuration targetRequest.reasoning = { effort: reasoningLevel, summary: 'auto' }; - } - // If request already has reasoning field, respect the configuration rule - // Remove it if model config is off/invalid, otherwise override with config - if (openaiRequest.reasoning) { - if (reasoningLevel) { - targetRequest.reasoning = { - effort: reasoningLevel, - summary: 'auto' - }; - } - // If reasoningLevel is null (off/invalid), don't add reasoning field + } else { + // If reasoning is off or invalid, explicitly remove reasoning field + // This ensures any reasoning field from the original request is deleted + delete targetRequest.reasoning; } // Pass through other parameters