feat(openrouter): disable reasoning if Request model reasoning is off and effort is minimum (#5079) * feat(openrouter): disable reasoning if "Request model reasoning" is disabled * feat(openrouter): map minimum reasoning to none if request reasoning is off * Add hint how to disable reasoning --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

0cef10f63f3d0239a53da5753fb53531012b1186

Brioch <134280928+Brioch@users.noreply.github.com>

Signed
3 files changed, +15 -5Ignore whitespace
public/index.html+4 -1
@@ -2129,7 +2129,7 @@
21292129 <span data-i18n="Allows the model to return its thinking process.">
21302130 Allows the model to return its thinking process.
21312131 </span>
21322132 <strong data-i18n="This setting affects visibility only." data-source-mode="except" data-source="zai,moonshot,openrouter">
21332133 This setting affects visibility only.
21342134 </strong>
21352135 </div>
@@ -2151,6 +2151,9 @@
21512151 <div class="toggle-description justifyLeft marginBot5" data-source="openai,custom,xai,aimlapi,openrouter,pollinations,perplexity,cometapi,electronhub,azure_openai,chutes" data-i18n="OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level.">
21522152 OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level.
21532153 </div>
2154+ <strong class="toggle-description justifyLeft marginBot5" data-source="openrouter">
2155+ Request model reasoning = Off with Reasoning Effort = Minimum disables reasoning entirely on models that support that, but can cause errors with some models.
2156+ </strong>
21542157 <div class="toggle-description justifyLeft marginBot5" data-source="claude" data-i18n="Allocates a portion of the response length for thinking (min: 1024 tokens, low: 10%, medium: 25%, high: 50%, max: 95%), but minimum 1024 tokens. Auto does not request thinking.">
21552158 Allocates a portion of the response length for thinking (min: 1024 tokens, low: 10%, medium: 25%, high: 50%, max: 95%), but minimum 1024 tokens. Auto does not request thinking.
21562159 </div>
public/scripts/openai.js+4 -0
@@ -2462,6 +2462,10 @@ function getReasoningEffort(settings = null, model = null) {
24622462 case reasoning_effort_types.auto:
24632463 return undefined;
24642464 case reasoning_effort_types.min:
2465+ if (chat_completion_sources.OPENROUTER === settings.chat_completion_source && !settings.show_thoughts) {
2466+ return 'none';
2467+ }
2468+
24652469 return [chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(settings.chat_completion_source) && /^gpt-5/.test(model)
24662470 ? reasoning_effort_types.min
24672471 : reasoning_effort_types.low;
src/endpoints/backends/chat-completions.js+7 -4
@@ -2070,10 +2070,13 @@ router.post('/generate', async function (request, response) {
20702070 apiKey = readSecret(request.user.directories, SECRET_KEYS.OPENROUTER);
20712071 // OpenRouter needs to pass the Referer and X-Title: https://openrouter.ai/docs#requests
20722072 headers = { ...OPENROUTER_HEADERS };
2073+ const includeReasoning = Boolean(request.body.include_reasoning);
20732074 bodyParams = {
20742075 'transforms': getOpenRouterTransforms(request),
20752076 'plugins': getOpenRouterPlugins(request),
2076- 'include_reasoning': Boolean(request.body.include_reasoning),
2077+ reasoning: {
2078+ exclude: !includeReasoning,
2079+ },
20772080 };
20782081
20792082 if (request.body.min_p !== undefined) {
@@ -2105,7 +2108,7 @@ router.post('/generate', async function (request, response) {
21052108 }
21062109
21072110 if (request.body.reasoning_effort) {
21082111 bodyParams['reasoning']['effort'] = { effort: request.body.reasoning_effort };
21092112 }
21102113
21112114 if (request.body.verbosity) {