HTTP 400: Unsupported parameter: 'max_tokens' is not supported with this model. ...
错误信息
HTTP 400: Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. (request id:
20260907222117763865247aZuo1Upw)
AI 解决方案
1. 🌐 错误翻译
原文:HTTP 400: Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. (request id: 20260907222117763865247aZuo1Upw)
译文:HTTP 400:不支持的参数:'max_tokens' 不适用于此模型。请改用 'max_completion_tokens'。(请求 id:20260907222117763865247aZuo1Upw)
2. 🎯 原因分析
max_tokens,该参数已被 max_completion_tokens 替代。max_tokens 参数,继续使用会导致参数校验失败,触发 400 错误。3. 💡 解决方案
将请求中的
max_tokens 参数替换为 max_completion_tokens,示例修复代码如下(以 Python 调用为例):# 修复前(错误写法)
response = client.chat.completions.create(
model="your-model-name",
messages=[{"role": "user", "content": "Hello"}],
max_tokens=1000 # 不兼容参数
)
# 修复后(正确写法)
response = client.chat.completions.create(
model="your-model-name",
messages=[{"role": "user", "content": "Hello"}],
max_completion_tokens=1000 # 兼容参数
)