mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-22 01:55:27 -04:00
OpenAI plugin get_num_tokens_from_messages() is not presently implemented for model gpt-5 #659
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yiqingqiu23187 on GitHub (Sep 18, 2025).
Originally assigned to: @crazywoola on GitHub.
Self Checks
Dify version
1.8.1
Plugin version
0.2.5(langgenius / openai)
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
How to reproduce:
Add an LLM node, select OpenAI's GPT-5 as the model provider, and such an error will occur after running:
[openai] Error: req_id: fd0afc4e14 PluginInvokeError: {"args":{},"error_type":"NotImplementedError","message":"get_num_tokens_from_messages() is not presently implemented for model gpt-5.See https://platform.openai.com/docs/advanced-usage/managing-tokens for for information on how messages are converted to tokens."}
After troubleshooting, I found that the problem lies in the _num_tokens_from_messages method in openAI plugin's langgenius-openai_0.2.5/models/llm/llm.py, where GPT-5 triggers the branch that raises NotImplementedError.
✔️ Error log
No response
@dosubot[bot] commented on GitHub (Sep 18, 2025):
Hi @yiqingqiu23187! I'm Dosu and I’m helping the dify-official-plugins team.
The error occurs because get_num_tokens_from_messages() is not implemented for GPT-5 in the OpenAI plugin. This is a known limitation: the plugin explicitly raises NotImplementedError for GPT-5 due to the lack of official tokenization details from OpenAI. While recent updates and pull requests have added GPT-5 model definitions and configuration files to the plugin, none implement token counting for GPT-5, and there are no workarounds or alternative approaches available at this time. The limitation will remain until OpenAI provides the necessary tokenization details or APIs for GPT-5, and the plugin is updated accordingly. You can track ongoing GPT-5 integration work in the plugin here: PR #1443, PR #1444, PR #1453, PR #1492, PR #1697.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
