Fail to access model(OpenAI-API-Compatible/glm-4.6v).Completions.create() got an...
错误信息
Fail to access model(OpenAI-API-Compatible/glm-4.6v).Completions.create() got an unexpected keyword argument 'unused'
AI 解决方案
错误翻译
原文:Completions.create() got an unexpected keyword argument 'unused'
译文:Completions.create() 收到了一个意外的关键字参数 'unused'
原因分析
根本原因是调用的 Completions.create() 方法不包含名为 unused 的参数。这通常发生在以下情况:
解决方案
直接移除调用 Completions.create() 时传递的 unused 关键字参数。
# ❌ 错误代码示例(包含无效参数)
# response = client.chat.completions.create(
# model="glm-4",
# messages=[...],
# unused="some_value" # 这个参数不被支持,会导致报错
# )
# ✅ 修复后的代码(移除无效参数)
response = client.chat.completions.create(
model="glm-4",
messages=[
{"role": "user", "content": "你好"}
]
# 已移除 'unused' 参数
)
️ 预防措施
kwargs:如果通过字典解包方式(如 config)传递参数,请仔细检查字典中是否包含了目标API不支持的键名,避免传入无效参数。