max_tokens: The maximum number of [tokens](/tokenizer) that can be generated in ...
错误信息
max_tokens: The maximum number of [tokens](/tokenizer) that can be generated in the chat
completion. This value can be used to control
[costs](https://openai.com/api/pricing/) for text generated via API.
This value is now deprecated in favor of `max_completion_tokens`, and is not
compatible with
[o-series models](https://platform.openai.com/docs/guides/reasoning).
AI 解决方案
max_tokens: 'max_completion_tokens` 的不推荐使用,且与 o 系列模型不兼容'
原因分析:max_tokens 参数已被弃用,并且与 O 系列模型不兼容。
解决方案:
请将代码中所有使用 max_tokens 的地方替换为 max_completion_tokens。
例如:
# 原有代码
response = openai.Completion.create(
model="text-davinci-003",
prompt="Say this is a test",
max_tokens=50
)
# 修改后代码
response = openai.Completion.create(
model="text-davinci-003",
prompt="Say this is a test",
max_completion_tokens=50
)
预防措施: