编辑模型 连接失败:API request failed with status 400:Unsupported paarameter: 'max_tokens...
错误信息
编辑模型
连接失败:API request failed with status 400:Unsupported paarameter: 'max_tokens' is not supported wi
th this model. Use 'max_completion_tokens' instead. (reqiuest id: 202610091010552865714758268d9d
69EX9KGB9)
AI 解决方案
原文:API request failed with status 400:Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.
译文:API请求失败,状态码400:不受支持的参数'max_tokens',该模型不支持此参数,请改用'max_completion_tokens'。
🎯 原因分析
错误原因是调用模型API时使用了参数
max_tokens,但当前模型不支持该参数,需替换为 max_completion_tokens。💡 解决方案
// 修复后的代码,将 max_tokens 替换为 max_completion_tokens
await openai.chat.completions.create({
model: "your-model-name",
messages: [{ role: "user", content: "请介绍DMXAPI平台" }],
max_completion_tokens: 500 // 替换为 max_completion_tokens
});