structured outputs not working for 4o-mini #8704

Closed
opened 2026-02-21 18:27:07 -05:00 by yindo · 20 comments
Owner

Originally created by @sugoh on GitHub (Feb 27, 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 search for existing issues, 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.0.0

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Create an LLM block
  2. Set model to 4o-mini
  3. Set Response Format to json_object
  4. Fill out JSON Schema field
  5. Toggle on both Response Format and JSON Schema
  6. Run

Note: It doesn't matter if you select json_object or json_schema, the error will be the same.

✔️ Expected Behavior

a JSON structured output.

Actual Behavior

Run failed: [openai] Error: PluginInvokeError: {"args":{"description":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"},"error_type":"InvokeError","message":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"}
Originally created by @sugoh on GitHub (Feb 27, 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 [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 (我已阅读并同意 [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.0.0 ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. Create an LLM block 2. Set model to `4o-mini` 3. Set Response Format to `json_object` 4. Fill out JSON Schema field 5. Toggle on both Response Format and JSON Schema 6. Run Note: It doesn't matter if you select `json_object` or `json_schema`, the error will be the same. ### ✔️ Expected Behavior a JSON structured output. ### ❌ Actual Behavior ``` Run failed: [openai] Error: PluginInvokeError: {"args":{"description":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"},"error_type":"InvokeError","message":"[models] Error: Completions.create() got an unexpected keyword argument 'json_schema'"} ```
yindo added the 🐞 buggood first issuecloud labels 2026-02-21 18:27:07 -05:00
yindo closed this issue 2026-02-21 18:27:07 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 27, 2025):

The issue you're encountering with the 4o-mini model is due to its lack of support for JSON Schema functionality. According to the documentation, only gpt-4o-mini-2024-07-18 and later versions, as well as gpt-4o-2024-08-06 and later versions, support JSON Schema. The 4o-mini model likely predates these versions and does not recognize the json_schema argument, resulting in the PluginInvokeError you're seeing [1].

A similar closed issue suggested setting the response_format to json_schema instead of json_object as a solution, but this may not apply to your case if the model itself does not support JSON Schema [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 27, 2025): <!-- Answer --> The issue you're encountering with the `4o-mini` model is due to its lack of support for JSON Schema functionality. According to the documentation, only `gpt-4o-mini-2024-07-18` and later versions, as well as `gpt-4o-2024-08-06` and later versions, support JSON Schema. The `4o-mini` model likely predates these versions and does not recognize the `json_schema` argument, resulting in the `PluginInvokeError` you're seeing <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/learn-more/how-to-use-json-schema-in-dify.md)</sup>. A similar closed issue suggested setting the `response_format` to `json_schema` instead of `json_object` as a solution, but this may not apply to your case if the model itself does not support JSON Schema <sup>[[2]](https://github.com/langgenius/dify/issues/10168)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/deee7f2f-360b-40aa-9aa5-b7ef829c4cf6?feedback_type=other)</sup>
Author
Owner

@Nothing1024 commented on GitHub (Feb 27, 2025):

same as you.
the old version doesn't show the error, but it doesn't have the json_schema-style output, just streaming text.
I thought something maybe happen in OPENAI.
Now, half of my projects can't work, I am trying to change the claude ;;

--update--

I try to request by curl with the json_schema method, and get the response of normal format.

"choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": ""
      },
      "finish_reason": "stop"
    }
  ],

--update--

I try the python demo from Structured Outputs Offical and get the right format. I can't locate the error rigth now.

@Nothing1024 commented on GitHub (Feb 27, 2025): same as you. the old version doesn't show the error, but it doesn't have the json_schema-style output, just streaming text. I thought something maybe happen in OPENAI. Now, half of my projects can't work, I am trying to change the claude ;; --update-- I try to request by curl with the json_schema method, and get the response of normal format. ```bash "choices": [ { "index": 0, "message": { "role": "assistant", "content": "" }, "finish_reason": "stop" } ], ``` --update-- I try the python demo from [Structured Outputs Offical](https://platform.openai.com/docs/guides/structured-outputs) and get the right format. I can't locate the error rigth now.
Author
Owner

@OrWestSide commented on GitHub (Feb 27, 2025):

Same issue here.

@OrWestSide commented on GitHub (Feb 27, 2025): Same issue here.
Author
Owner

@elliottsharp commented on GitHub (Feb 27, 2025):

experiencing the same issue

@elliottsharp commented on GitHub (Feb 27, 2025): experiencing the same issue
Author
Owner

@alitayin commented on GitHub (Feb 27, 2025):

Same here. it works for the past months until today.

@alitayin commented on GitHub (Feb 27, 2025): Same here. it works for the past months until today.
Author
Owner

@yamaneko1212 commented on GitHub (Feb 27, 2025):

I got the similar issue using GPT-4o-2024-11-20.

@yamaneko1212 commented on GitHub (Feb 27, 2025): I got the similar issue using GPT-4o-2024-11-20.
Author
Owner

@crazywoola commented on GitHub (Feb 27, 2025):

For anyone who is interested working on this, please submit a pull request to https://github.com/langgenius/dify-official-plugins.

@crazywoola commented on GitHub (Feb 27, 2025): For anyone who is interested working on this, please submit a pull request to https://github.com/langgenius/dify-official-plugins.
Author
Owner

@yamaneko1212 commented on GitHub (Feb 28, 2025):

I got an answer from dify support team via mail.
In my case, upgrading OpenAI plugin and reconfigure settings solve the issue.

@yamaneko1212 commented on GitHub (Feb 28, 2025): I got an answer from dify support team via mail. In my case, upgrading OpenAI plugin and reconfigure settings solve the issue.
Author
Owner

@elliottsharp commented on GitHub (Feb 28, 2025):

just tested this after upgrading the OpenAI plugin, it works again

@elliottsharp commented on GitHub (Feb 28, 2025): just tested this after upgrading the OpenAI plugin, it works again
Author
Owner

@Nothing1024 commented on GitHub (Feb 28, 2025):

I try to upgrade the OpenAI plugin at 13:00 and doesn't work.
I try again after comments with same settings and get the correct result.
IDK, it's ok.

--- update ---

it's broken again ;;

@Nothing1024 commented on GitHub (Feb 28, 2025): I try to upgrade the OpenAI plugin at 13:00 and doesn't work. I try again after comments with same settings and get the correct result. IDK, it's ok. --- update --- it's broken again ;;
Author
Owner

@ymshenyu commented on GitHub (Feb 28, 2025):

same with azure openai

@ymshenyu commented on GitHub (Feb 28, 2025): same with azure openai
Author
Owner

@ymshenyu commented on GitHub (Feb 28, 2025):

I have no idea why the response_format isn’t present in the model_parameters.

Image

Image

@ymshenyu commented on GitHub (Feb 28, 2025): I have no idea why the `response_format` isn’t present in the `model_parameters`. ![Image](https://github.com/user-attachments/assets/6a8cf5b8-6ae2-442d-9efa-aa3381a80792) ![Image](https://github.com/user-attachments/assets/2395e6a1-47d1-4fb6-9313-f88bb5c83331)
Author
Owner

@Nothing1024 commented on GitHub (Mar 1, 2025):

try to change the model id gpt-4o-2024-08-06, it's ok.

@Nothing1024 commented on GitHub (Mar 1, 2025): try to change the model id `gpt-4o-2024-08-06`, it's ok.
Author
Owner

@ymshenyu commented on GitHub (Mar 1, 2025):

try to change the model id gpt-4o-2024-08-06, it's ok.

We can't, that's not a solution for azure openai.

@ymshenyu commented on GitHub (Mar 1, 2025): > try to change the model id `gpt-4o-2024-08-06`, it's ok. We can't, that's not a solution for azure openai.
Author
Owner

@medaka0213 commented on GitHub (Mar 2, 2025):

I installed latest(=v0.0.10?) OpenAI pugins but still same issue...
Using GPT-4o-2024-11-20

@medaka0213 commented on GitHub (Mar 2, 2025): I installed latest(=v0.0.10?) OpenAI pugins but still same issue... Using GPT-4o-2024-11-20
Author
Owner

@ymshenyu commented on GitHub (Mar 3, 2025):

@crazywoola This issue is related to the plugin sdk. Could you follow up on my PR? Thanks.

@ymshenyu commented on GitHub (Mar 3, 2025): @crazywoola This issue is related to the plugin sdk. Could you follow up on my PR? Thanks.
Author
Owner

@ymshenyu commented on GitHub (Mar 4, 2025):

@medaka0213 I made a patch that overrides the superclass method. Feel free to test it if you like.
https://github.com/ymshenyu/dify-official-plugins/actions/runs/13646714841

@ymshenyu commented on GitHub (Mar 4, 2025): @medaka0213 I made a patch that overrides the superclass method. Feel free to test it if you like. https://github.com/ymshenyu/dify-official-plugins/actions/runs/13646714841
Author
Owner

@crazywoola commented on GitHub (Mar 20, 2025):

@crazywoola This issue is related to the plugin sdk. Could you follow up on my PR? Thanks.

I have forwarded already, I do not have the review access for that repo. :(

@crazywoola commented on GitHub (Mar 20, 2025): > [@crazywoola](https://github.com/crazywoola) This issue is related to the plugin sdk. Could you follow up on my PR? Thanks. I have forwarded already, I do not have the review access for that repo. :(
Author
Owner

@kurokobo commented on GitHub (Mar 20, 2025):

This is regression of #8451, and #9148 by @hjlarry should be re-applied.

I've opened PR for this: https://github.com/langgenius/dify-plugin-sdks/pull/57
For Azure OpenAI users, I've also opened PR which includes workaround for this: https://github.com/langgenius/dify-official-plugins/pull/521

@kurokobo commented on GitHub (Mar 20, 2025): This is regression of #8451, and #9148 by @hjlarry should be re-applied. I've opened PR for this: https://github.com/langgenius/dify-plugin-sdks/pull/57 For Azure OpenAI users, I've also opened PR which includes workaround for this: https://github.com/langgenius/dify-official-plugins/pull/521
Author
Owner

@CorrectRoadH commented on GitHub (Apr 6, 2025):

I got same issue in dify cloud. and i can't use gpt-4o-2024-08-06. any solution is work for me?

@CorrectRoadH commented on GitHub (Apr 6, 2025): I got same issue in dify cloud. and i can't use gpt-4o-2024-08-06. any solution is work for me?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8704