OpenAI-API-compatible plugin doesn't work for reasoning models (e.g. GPT-5) #703

Closed
opened 2026-02-16 10:20:14 -05:00 by yindo · 6 comments
Owner

Originally created by @opeco17 on GitHub (Oct 12, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.1

Cloud or Self Hosted

Self Hosted (Source), Self Hosted (Docker)

Steps to reproduce

  1. Go to Settings -> Model Provider -> OpenAI-API-compatible -> Add Model
  2. Input "gpt-5" for Model Name and "LLM" for Model Type
  3. Click "Add" and error happens below
Credentials validation failed with status code 400 and response body { "error": { "message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", "type": "invalid_request_error", "param": "max_tokens", "code": "unsupported_parameter" } }

✔️ Expected Behavior

GPT-5 can be saved and used without any issues.

Actual Behavior

Error happens

Originally created by @opeco17 on GitHub (Oct 12, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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 [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Cloud or Self Hosted Self Hosted (Source), Self Hosted (Docker) ### Steps to reproduce 1. Go to Settings -> Model Provider -> OpenAI-API-compatible -> Add Model 2. Input "gpt-5" for Model Name and "LLM" for Model Type 3. Click "Add" and error happens below ``` Credentials validation failed with status code 400 and response body { "error": { "message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", "type": "invalid_request_error", "param": "max_tokens", "code": "unsupported_parameter" } } ``` ### ✔️ Expected Behavior GPT-5 can be saved and used without any issues. ### ❌ Actual Behavior Error happens
yindo added the bug label 2026-02-16 10:20:14 -05:00
yindo closed this issue 2026-02-16 10:20:14 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 12, 2025):

Hi @opeco17! I'm Dosu and I’m helping the dify team.

This issue happens because Dify’s OpenAI-API-compatible integration expects the standard max_tokens parameter, but newer models like GPT-5 require max_completion_tokens instead. The parameter mapping logic in Dify is currently static for OpenAI-compatible providers, so it doesn’t automatically translate or support non-standard parameters out of the box.

Several users have reported similar problems with other models, and the recommended workaround is to use the "OpenAI" provider directly instead of the "OpenAI-API-compatible" provider, which sometimes resolves parameter validation issues for custom models. If you need to use the compatible provider, you may need to manually adjust the backend model configuration (such as the YAML files in the dify-official-plugins repo) to expose and set max_completion_tokens instead of max_tokens, then restart the relevant services for changes to take effect. This approach has helped others with similar errors for models like Qwen3 and custom LLMs [discussion] [issue].

If you’re running into this with GPT-5, check if switching providers or updating the backend config resolves it. Otherwise, a code update to make parameter mapping more flexible for OpenAI-compatible plugins may be needed.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 12, 2025): <!-- Greeting --> Hi @opeco17! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This issue happens because Dify’s OpenAI-API-compatible integration expects the standard `max_tokens` parameter, but newer models like GPT-5 require `max_completion_tokens` instead. The parameter mapping logic in Dify is currently static for OpenAI-compatible providers, so it doesn’t automatically translate or support non-standard parameters out of the box. Several users have reported similar problems with other models, and the recommended workaround is to use the "OpenAI" provider directly instead of the "OpenAI-API-compatible" provider, which sometimes resolves parameter validation issues for custom models. If you need to use the compatible provider, you may need to manually adjust the backend model configuration (such as the YAML files in the dify-official-plugins repo) to expose and set `max_completion_tokens` instead of `max_tokens`, then restart the relevant services for changes to take effect. This approach has helped others with similar errors for models like Qwen3 and custom LLMs [[discussion](https://github.com/langgenius/dify/discussions/25154#discussioncomment-14305499)] [[issue](https://github.com/langgenius/dify/issues/15495#issuecomment-2723331587)]. If you’re running into this with GPT-5, check if switching providers or updating the backend config resolves it. Otherwise, a code update to make parameter mapping more flexible for OpenAI-compatible plugins may be needed. <!-- 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/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/567851a6-0ccb-4e37-beb1-faff37397258?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&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/issues/26806)
Author
Owner

@opeco17 commented on GitHub (Oct 12, 2025):

This is because deprecated parameter max_tokens is used for the validation (ref).
https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/interfaces/model/openai_compatible/llm.py#L183

The easiest way is to remove this parameter for the validation and restrict the length of the output using prompt like "Reply with single word".

If this direction is fine, I can work on the fix.

@opeco17 commented on GitHub (Oct 12, 2025): This is because deprecated parameter `max_tokens` is used for the validation ([ref](https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens)). https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/interfaces/model/openai_compatible/llm.py#L183 The easiest way is to remove this parameter for the validation and restrict the length of the output using prompt like "Reply with single word". If this direction is fine, I can work on the fix.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 12, 2025):

The error happens because Dify's OpenAI-API-compatible plugin expects the 'max_tokens' parameter, but reasoning models like GPT-5 require 'max_completion_tokens' instead. Dify's parameter mapping doesn't currently account for this model-specific difference, so validation fails and the model can't be added without changes.

Recent updates have improved parameter handling and made it more flexible, especially with the introduction of "advanced mode" in the UI. This mode allows you to configure parameters that aren't part of the default set, as long as the provider's schema supports them. However, automatic mapping between 'max_tokens' and 'max_completion_tokens' is not built-in—you need to ensure the provider/plugin schema lists the correct parameters for your model (like 'max_completion_tokens' for GPT-5) and use advanced mode to set them. This design future-proofs Dify for evolving LLM APIs, but for now, supporting GPT-5 or similar models may require updating the provider schema or parameter mapping logic to recognize and accept 'max_completion_tokens' instead of 'max_tokens' see details.

If you need to support GPT-5 immediately, check your provider's schema and update it to include 'max_completion_tokens', then use advanced mode to set it in the UI. This should resolve the validation error and allow you to add and use the model.

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 (Oct 12, 2025): <!-- Answer --> The error happens because Dify's OpenAI-API-compatible plugin expects the 'max_tokens' parameter, but reasoning models like GPT-5 require 'max_completion_tokens' instead. Dify's parameter mapping doesn't currently account for this model-specific difference, so validation fails and the model can't be added without changes. Recent updates have improved parameter handling and made it more flexible, especially with the introduction of "advanced mode" in the UI. This mode allows you to configure parameters that aren't part of the default set, as long as the provider's schema supports them. However, automatic mapping between 'max_tokens' and 'max_completion_tokens' is not built-in—you need to ensure the provider/plugin schema lists the correct parameters for your model (like 'max_completion_tokens' for GPT-5) and use advanced mode to set them. This design future-proofs Dify for evolving LLM APIs, but for now, supporting GPT-5 or similar models may require updating the provider schema or parameter mapping logic to recognize and accept 'max_completion_tokens' instead of 'max_tokens' [see details](https://github.com/langgenius/dify/pull/25963). If you need to support GPT-5 immediately, check your provider's schema and update it to include 'max_completion_tokens', then use advanced mode to set it in the UI. This should resolve the validation error and allow you to add and use the model. <!-- 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/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2bfe3ad9-13e6-43f3-8ef4-3c11d3433d0b?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/1845)
Author
Owner

@Haddyshu commented on GitHub (Oct 24, 2025):

Hello, I have encountered the same problem in the process of use. Is there any way to solve it at present?

@Haddyshu commented on GitHub (Oct 24, 2025): Hello, I have encountered the same problem in the process of use. Is there any way to solve it at present?
Author
Owner

@chupark commented on GitHub (Oct 29, 2025):

I've created two PRs to address this issue. I hope these PRs will be merged.

@chupark commented on GitHub (Oct 29, 2025): I've created two PRs to address this issue. I hope these PRs will be merged. - https://github.com/langgenius/dify-plugin-sdks/pull/231 - https://github.com/langgenius/dify-official-plugins/pull/1958
Author
Owner

@dosubot[bot] commented on GitHub (Nov 14, 2025):

Hi, @opeco17. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a 400 error when adding GPT-5 via Dify's OpenAI-API-compatible plugin due to the deprecated "max_tokens" parameter.
  • The issue stems from Dify's static parameter mapping expecting "max_tokens" instead of GPT-5's "max_completion_tokens."
  • Workarounds included using the "OpenAI" provider or updating backend configurations.
  • Recent improvements introduced an "advanced mode" for custom parameters.
  • User chupark submitted PRs updating the schema and backend to fully support "max_completion_tokens," resolving the error.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of dify-official-plugins by commenting here.
  • If no further updates are provided, I will automatically close this issue in 5 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Nov 14, 2025): Hi, @opeco17. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a 400 error when adding GPT-5 via Dify's OpenAI-API-compatible plugin due to the deprecated "max_tokens" parameter. - The issue stems from Dify's static parameter mapping expecting "max_tokens" instead of GPT-5's "max_completion_tokens." - Workarounds included using the "OpenAI" provider or updating backend configurations. - Recent improvements introduced an "advanced mode" for custom parameters. - User chupark submitted PRs updating the schema and backend to fully support "max_completion_tokens," resolving the error. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of dify-official-plugins by commenting here. - If no further updates are provided, I will automatically close this issue in 5 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#703