OpenAI plugin get_num_tokens_from_messages() is not presently implemented for model gpt-5 #659

Closed
opened 2026-02-16 10:20:06 -05:00 by yindo · 1 comment
Owner

Originally created by @yiqingqiu23187 on GitHub (Sep 18, 2025).

Originally assigned to: @crazywoola on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Plugin version

0.2.5(langgenius / openai)

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image Image

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.

Image

✔️ Error log

No response

Originally created by @yiqingqiu23187 on GitHub (Sep 18, 2025). Originally assigned to: @crazywoola on GitHub. ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Plugin version 0.2.5(langgenius / openai) ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce <img width="1530" height="439" alt="Image" src="https://github.com/user-attachments/assets/5af0b9d7-e9c2-416f-aa4b-c55b1f2a49b9" /> <img width="1618" height="379" alt="Image" src="https://github.com/user-attachments/assets/bf8585cf-63d6-4d11-9c23-4f6396cc9c44" /> 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. <img width="815" height="485" alt="Image" src="https://github.com/user-attachments/assets/58b0e6aa-7345-46d1-a8f6-b9d4723b53a0" /> ### ✔️ Error log _No response_
yindo added the bug label 2026-02-16 10:20:06 -05:00
yindo closed this issue 2026-02-16 10:20:06 -05:00
Author
Owner

@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  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 18, 2025): <!-- Greeting --> Hi @yiqingqiu23187! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify-official-plugins team. <!-- Answer --> 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](https://github.com/langgenius/dify-official-plugins/pull/1443), [PR #1444](https://github.com/langgenius/dify-official-plugins/pull/1444), [PR #1453](https://github.com/langgenius/dify-official-plugins/pull/1453), [PR #1492](https://github.com/langgenius/dify-official-plugins/pull/1492), [PR #1697](https://github.com/langgenius/dify-official-plugins/pull/1697). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/15bef98d-a48f-41c7-b7fa-7d2bb1093363?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1734)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#659