Skip to content

Commit 58a2155

Browse files
hydropixclaude
andcommitted
fix: don't send thinking params to official OpenAI API (#115)
The OpenAI-compatible provider was sending `thinking`, `enable_thinking`, and `chat_template_kwargs` parameters to all endpoints including the official OpenAI API, which rejects unrecognized arguments with a 400 error. These params are now only sent to local/compatible servers (LM Studio, llama.cpp, vLLM, etc.). Closes #115 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8a2fe11 commit 58a2155

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/core/llm/providers/openai.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def __init__(self, api_endpoint: str, model: str, api_key: Optional[str] = None,
3434
self._detected_context_size: Optional[int] = None
3535
self._context_detector = ContextDetector()
3636

37+
def _is_official_openai_endpoint(self) -> bool:
38+
"""Check if the endpoint is the official OpenAI API."""
39+
return "api.openai.com" in self.api_endpoint
40+
3741
@staticmethod
3842
def _normalize_endpoint(endpoint: str) -> str:
3943
"""
@@ -94,16 +98,14 @@ async def generate(self, prompt: str, timeout: int = REQUEST_TIMEOUT,
9498
"model": self.model,
9599
"messages": messages,
96100
"stream": False,
97-
# Disable thinking/reasoning mode for local servers and compatible APIs
98-
# This prevents models from outputting <think>...</think> blocks
99-
"thinking": False,
100-
"enable_thinking": False,
101-
# Some servers use chat_template_kwargs
102-
"chat_template_kwargs": {
103-
"enable_thinking": False
104-
}
105101
}
106102

103+
# Only add thinking-disable params for local/compatible servers, not official OpenAI API
104+
if not self._is_official_openai_endpoint():
105+
payload["thinking"] = False
106+
payload["enable_thinking"] = False
107+
payload["chat_template_kwargs"] = {"enable_thinking": False}
108+
107109
client = await self._get_client()
108110
for attempt in range(MAX_TRANSLATION_ATTEMPTS):
109111
try:

0 commit comments

Comments
 (0)