From 54e01d617d0b7ab0d638e0ff88579c7c97089b1a Mon Sep 17 00:00:00 2001 From: Blade096 <46746496+Blade096@users.noreply.github.com> Date: Sat, 7 Feb 2026 21:35:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(translator):=20add=20thinking=20parameter?= =?UTF-8?q?=20support=20in=20OpenAI=20=E2=86=92=20Claude?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserve thinking configuration when converting OpenAI requests to Claude format. - Handle thinking.type with 'enabled' as default - Preserve thinking.budget_tokens when present - Preserve thinking.max_tokens when present This enables proper thinking mode support for o1-series models when routed through 9Router to Claude endpoints. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus (cherry picked from commit 65d80e9269cc6789cb1522b276e8b8399fddbcab) --- open-sse/translator/request/openai-to-claude.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/open-sse/translator/request/openai-to-claude.js b/open-sse/translator/request/openai-to-claude.js index 8ab5918..bfed352 100644 --- a/open-sse/translator/request/openai-to-claude.js +++ b/open-sse/translator/request/openai-to-claude.js @@ -141,6 +141,15 @@ export function openaiToClaudeRequest(model, body, stream) { result.tool_choice = convertOpenAIToolChoice(body.tool_choice); } + // Thinking configuration + if (body.thinking) { + result.thinking = { + type: body.thinking.type || "enabled", + ...(body.thinking.budget_tokens && { budget_tokens: body.thinking.budget_tokens }), + ...(body.thinking.max_tokens && { max_tokens: body.thinking.max_tokens }) + }; + } + // Attach toolNameMap to result for response translation if (toolNameMap.size > 0) { result._toolNameMap = toolNameMap;