_from_response(err.response) from None openai.BadRequestError: Error code: 400 -...
错误信息
File "c:\ProgramData\anaconda3\Lib\site-packages\openai\_base_client.py", line 1034, in request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Error from provider (DeepSeek): thinking options type cannot be disabled when reasoning_effort is set', 'type': 'invalid_request_error', 'param': '', 'code': 'invalid_request_error'}}
AI 解决方案
报错分析报告
1.错误翻译
原文:Error from provider (DeepSeek): thinking options type cannot be disabled when reasoning_effort is set
译文:来自提供商(DeepSeek)的错误:当设置reasoning_effort时,无法禁用思考选项类型
2. 原因分析
reasoning_effort参数与禁用thinking options type,两者存在冲突。 _base_client.py第1034行),由DeepSeek提供商返回invalid_request_error。3.解决方案
调整参数组合,避免冲突。以下是修复示例(以Python为例):
# 方案1:保留reasoning_effort,启用thinking options(推荐)
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "你的问题"}],
reasoning_effort="high" # 仅设置该参数,不禁用thinking
)
# 方案2:如需禁用thinking options,移除reasoning_effort
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "你的问题"}],
thinking={"disabled": True} # 仅禁用thinking,不设置reasoning_effort
)
4. 预防措施
reasoning_effort和thinking.disabled=True)。 ---
注:修复需根据实际业务场景选择参数组合,优先参考官方最新文档。