Structured output error using openai_api_compatible #584

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

Originally created by @BBYNAI on GitHub (Aug 24, 2025).

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.7.2

Plugin version

openai_api_compatible 0.0.20

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Setup the model:

  1. Install the dify plugin: openai_api_compatible v0.0.20.
  2. Add a model that supports structured output (i.e gpt-4.1-mini).
  3. Set Function Calling to "Tool Call" and Structured Output to "Support".

Test Structured Output:

  1. Create a new blank Chatflow.
  2. In the LLM node, select the previously created model from the openai_api_compatible plugin.
  3. In the LLM node, enable structured output and add a string field named "answer".
  4. Test a the chatflow with a query such as "hello world".

Chatflow reference: structured output test.yml

✔️ Error log

The errors below are shown in the Dify conversation after sending "hello world".

When using OpenAI as the backend with OpenAI-API-Compatible plugin:

Run failed: [openai_api_compatible] Error: req_id: XXXXXXXXXX PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {"error":{"message":"Unknown parameter: 'response_format.json_schema'.","type":"invalid_request_error","param":"response_format.json_schema","code":"unknown_parameter"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {"error":{"message":"Unknown parameter: 'response_format.json_schema'.","type":"invalid_request_error","param":"response_format.json_schema","code":"unknown_parameter"}}"}

When using LiteLLM as the backend with OpenAI-API-Compatible plugin:

Run failed: [openai_api_compatible] Error: req_id: XXXXXXXXXX PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {"error":{"message":"litellm.BadRequestError: OpenAIException - Unrecognized request argument supplied: json_schema. Received Model Group=gpt-4.1-mini\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":null,"code":"400"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {"error":{"message":"litellm.BadRequestError: OpenAIException - Unrecognized request argument supplied: json_schema. Received Model Group=gpt-4.1-mini\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":null,"code":"400"}}"}
Originally created by @BBYNAI on GitHub (Aug 24, 2025). ### 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.7.2 ### Plugin version openai_api_compatible 0.0.20 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce **Setup the model:** 1. Install the dify plugin: openai_api_compatible v0.0.20. 2. Add a model that supports structured output (i.e gpt-4.1-mini). 3. Set Function Calling to "Tool Call" and Structured Output to "Support". **Test Structured Output:** 1. Create a new blank Chatflow. 2. In the LLM node, select the previously created model from the openai_api_compatible plugin. 3. In the LLM node, enable structured output and add a string field named "answer". 4. Test a the chatflow with a query such as "hello world". Chatflow reference: [structured output test.yml](https://github.com/user-attachments/files/21956460/structured.output.test.yml) ### ✔️ Error log The errors below are shown in the Dify conversation after sending "hello world". When using OpenAI as the backend with OpenAI-API-Compatible plugin: ``` Run failed: [openai_api_compatible] Error: req_id: XXXXXXXXXX PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {"error":{"message":"Unknown parameter: 'response_format.json_schema'.","type":"invalid_request_error","param":"response_format.json_schema","code":"unknown_parameter"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {"error":{"message":"Unknown parameter: 'response_format.json_schema'.","type":"invalid_request_error","param":"response_format.json_schema","code":"unknown_parameter"}}"} ``` When using LiteLLM as the backend with OpenAI-API-Compatible plugin: ``` Run failed: [openai_api_compatible] Error: req_id: XXXXXXXXXX PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {"error":{"message":"litellm.BadRequestError: OpenAIException - Unrecognized request argument supplied: json_schema. Received Model Group=gpt-4.1-mini\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":null,"code":"400"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {"error":{"message":"litellm.BadRequestError: OpenAIException - Unrecognized request argument supplied: json_schema. Received Model Group=gpt-4.1-mini\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":null,"code":"400"}}"} ```
yindo added the bug label 2026-02-16 10:19:49 -05:00
yindo closed this issue 2026-02-16 10:19:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 24, 2025):

Hi @BBYNAI! I'm Dosu and I’m helping the dify-official-plugins team.

The error happens because the backend (OpenAI or LiteLLM) doesn't recognize the json_schema or response_format.json_schema parameters sent by the openai_api_compatible plugin. This is a known compatibility issue: not all OpenAI-compatible endpoints support these structured output features, especially with models like gpt-4.1-mini. The plugin v0.0.20 includes a workaround that should intercept response_format=json_schema and instead inject the schema as a system prompt, but this only works if the plugin and backend are correctly configured and the model actually supports structured output natively. If the backend still rejects the parameter, structured output will fail with a 400 error source.

To resolve this, make sure you are using the latest plugin version and a model that explicitly supports JSON Schema (for example, gpt-4o-mini-2024-07-18 or later). If your backend does not support these parameters, Dify will fall back to prompt-based formatting, which is less reliable. If strict structured output is required, you may need to upgrade your backend/model or use a provider that supports native JSON Schema source.

If you continue to see this error even with the latest plugin and a supported model, double-check your plugin configuration and model selection. For most cases, upgrading and reconfiguring should resolve the issue source.

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 (Aug 24, 2025): <!-- Greeting --> Hi @BBYNAI! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify-official-plugins team. <!-- Answer --> The error happens because the backend (OpenAI or LiteLLM) doesn't recognize the `json_schema` or `response_format.json_schema` parameters sent by the openai_api_compatible plugin. This is a known compatibility issue: not all OpenAI-compatible endpoints support these structured output features, especially with models like gpt-4.1-mini. The plugin v0.0.20 includes a workaround that should intercept `response_format=json_schema` and instead inject the schema as a system prompt, but this only works if the plugin and backend are correctly configured and the model actually supports structured output natively. If the backend still rejects the parameter, structured output will fail with a 400 error [source](https://github.com/langgenius/dify-official-plugins/issues/730#issuecomment-2808083193). To resolve this, make sure you are using the latest plugin version and a model that explicitly supports JSON Schema (for example, gpt-4o-mini-2024-07-18 or later). If your backend does not support these parameters, Dify will fall back to prompt-based formatting, which is less reliable. If strict structured output is required, you may need to upgrade your backend/model or use a provider that supports native JSON Schema [source](https://github.com/langgenius/dify-official-plugins/pull/1494). If you continue to see this error even with the latest plugin and a supported model, double-check your plugin configuration and model selection. For most cases, upgrading and reconfiguring should resolve the issue [source](https://github.com/langgenius/dify-official-plugins/issues/577). <!-- 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/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/795d5442-02b6-482e-9922-a95bad5979da?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/1568)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#584