From b90a8423f167949f972e4ab45ad1052c359982d6 Mon Sep 17 00:00:00 2001 From: _WD_ <68629279+0WD0@users.noreply.github.com> Date: Fri, 18 Jul 2025 10:10:24 +0800 Subject: [PATCH] fix: API call error for Grok reasoning model via OpenRouter (#8252) fix: openrouter reasoning disabled error --- .../src/aiCore/clients/openai/OpenAIApiClient.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts index b4e5805724..f7b88aeda6 100644 --- a/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts +++ b/src/renderer/src/aiCore/clients/openai/OpenAIApiClient.ts @@ -5,6 +5,7 @@ import { GEMINI_FLASH_MODEL_REGEX, getOpenAIWebSearchParams, isDoubaoThinkingAutoModel, + isGrokReasoningModel, isQwenReasoningModel, isReasoningModel, isSupportedReasoningEffortGrokModel, @@ -117,11 +118,12 @@ export class OpenAIAPIClient extends OpenAIBaseClient< if (!reasoningEffort) { if (model.provider === 'openrouter') { - if ( - isSupportedThinkingTokenGeminiModel(model) && - !GEMINI_FLASH_MODEL_REGEX.test(model.id) && - model.id.includes('grok-4') - ) { + // Don't disable reasoning for Gemini models that support thinking tokens + if (isSupportedThinkingTokenGeminiModel(model) && !GEMINI_FLASH_MODEL_REGEX.test(model.id)) { + return {} + } + // Don't disable reasoning for models that require it + if (isGrokReasoningModel(model)) { return {} } return { reasoning: { enabled: false, exclude: true } }