[openai] Error: Completions.create() got an unexpected keyword argument 'json_schema' #6494

Closed
opened 2026-02-21 18:15:59 -05:00 by yindo · 6 comments
Owner

Originally created by @genru on GitHub (Nov 1, 2024).

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

0.10.2

Cloud or Self Hosted

Cloud

Steps to reproduce

LLM node, select gpt-4o-mini mode(azure version) with json_schema, setting response format as json_object as well.

belowing is the schema

{
    "name": "sences",
    "description": "generate sences from scripts",
    "strict": true,
    "schema": {
        "type": "object",
        "properties": {
            "prompts": {
                "type": "array",
                "items": {
                    "name": "prompt",
                    "type": "string",
                    "description": "prompts text"
                }
            }        
        },
        "required": ["prompts"],
        "additionalProperties": false
    }
}

when run this node will cause this issue.

i also attached the parameters for your reference.
image

✔️ Expected Behavior

run llm node successfully. I noticed the #8451, but this issue seems to remain.

Actual Behavior

[openai] Error: Completions.create() got an unexpected keyword argument 'json_schema' displayed.

Originally created by @genru on GitHub (Nov 1, 2024). ### 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 0.10.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce LLM node, select gpt-4o-mini mode(azure version) with `json_schema`, setting `response format` as `json_object` as well. belowing is the schema ```js { "name": "sences", "description": "generate sences from scripts", "strict": true, "schema": { "type": "object", "properties": { "prompts": { "type": "array", "items": { "name": "prompt", "type": "string", "description": "prompts text" } } }, "required": ["prompts"], "additionalProperties": false } } ``` when run this node will cause this issue. i also attached the parameters for your reference. <img width="370" alt="image" src="https://github.com/user-attachments/assets/ce00d82a-58a1-4f59-81ca-dde800b3b449"> ### ✔️ Expected Behavior run llm node successfully. I noticed the #8451, but this issue seems to remain. ### ❌ Actual Behavior `[openai] Error: Completions.create() got an unexpected keyword argument 'json_schema' ` displayed.
yindo added the 🐞 bug label 2026-02-21 18:15:59 -05:00
yindo closed this issue 2026-02-21 18:16:00 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 1, 2024):

@genru Hello! I'm here to help you with any bugs, questions, or contributions. Let's get started!

The error you're encountering indicates that the Completions.create() method does not support the json_schema argument. This suggests that the method's implementation in the Dify platform does not include json_schema as a valid parameter.

To resolve this issue, you should verify the method's documentation or source code to ensure that json_schema is indeed a supported argument. If it is not, you may need to adjust your implementation to align with the supported parameters of the Completions.create() method. According to the available information, the method typically includes parameters like model, prompt, stream, and additional keyword arguments (**kwargs) [1].

If json_schema is intended to be used, it might require a different approach or configuration within the Dify platform. You may want to check for any updates or changes in the platform's documentation or reach out to the maintainers for further clarification on how to properly implement JSON Schema with the current version of the platform.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 1, 2024): <!-- Greeting --> @genru Hello! I'm here to help you with any bugs, questions, or contributions. Let's get started! <!-- Answer --> The error you're encountering indicates that the `Completions.create()` method does not support the `json_schema` argument. This suggests that the method's implementation in the Dify platform does not include `json_schema` as a valid parameter. To resolve this issue, you should verify the method's documentation or source code to ensure that `json_schema` is indeed a supported argument. If it is not, you may need to adjust your implementation to align with the supported parameters of the `Completions.create()` method. According to the available information, the method typically includes parameters like `model`, `prompt`, `stream`, and additional keyword arguments (`**kwargs`) <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/tests/integration_tests/model_runtime/__mock/openai_completion.py)</sup>. If `json_schema` is intended to be used, it might require a different approach or configuration within the Dify platform. You may want to check for any updates or changes in the platform's documentation or reach out to the maintainers for further clarification on how to properly implement JSON Schema with the current version of the platform. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Nov 1, 2024):

See this https://github.com/langgenius/dify/issues/8994#issuecomment-2395359831 as well.

@crazywoola commented on GitHub (Nov 1, 2024): See this https://github.com/langgenius/dify/issues/8994#issuecomment-2395359831 as well.
Author
Owner

@hjlarry commented on GitHub (Nov 1, 2024):

you should set response_format to json_schema to make it works.
and if we raise clear error in this situation maybe better

@hjlarry commented on GitHub (Nov 1, 2024): you should set `response_format` to `json_schema` to make it works. and if we raise clear error in this situation maybe better
Author
Owner

@genru commented on GitHub (Nov 1, 2024):

thanks @crazywoola. yes, i met the same issue, it seems caused by azure? i wonder if there is any solution or workaround for it?

@hjlarry I think I have set response_format, as I attached the settings screenshot shows, or I missed anything?

@genru commented on GitHub (Nov 1, 2024): thanks @crazywoola. yes, i met the same issue, it seems caused by azure? i wonder if there is any solution or workaround for it? @hjlarry I think I have set `response_format`, as I attached the settings screenshot shows, or I missed anything?
Author
Owner

@hjlarry commented on GitHub (Nov 1, 2024):

@hjlarry I think I have set response_format, as I attached the settings screenshot shows, or I missed anything?

in your screenshot, you set response_format to json_object not json_schema

@hjlarry commented on GitHub (Nov 1, 2024): > @hjlarry I think I have set `response_format`, as I attached the settings screenshot shows, or I missed anything? in your screenshot, you set `response_format` to `json_object` not `json_schema`
Author
Owner

@genru commented on GitHub (Nov 1, 2024):

@hjlarry thanks so much, you made my day. it's my bad, it works now.

thanks guys. issue closed

@genru commented on GitHub (Nov 1, 2024): @hjlarry thanks so much, you made my day. it's my bad, it works now. thanks guys. issue closed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6494