Unable to pass json_schema parameter in OpenAI-API-compatible custom model #198

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

Originally created by @liguoxun001 on GitHub (Apr 15, 2025).

Self Checks

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

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Description:

When using the OpenAI-API-compatible feature to add a custom model, I found that the json_schema parameter (used for response format control, e.g., response_format={ "type": "json_object", "schema": {...} }) cannot be passed through the API request. This limits the ability to enforce structured JSON output from the custom model, which is a critical feature for many use cases.

Steps to Reproduce:

  1. Add a custom model via the OpenAI-API-compatible interface.

  2. Attempt to make a request with response_format or json_schema in the payload, e.g.:

{ "model": "custom-model-name", "messages": [...], "response_format": { "type": "json_object", "schema": { "type": "object", "properties": {...} } } }

  1. Observe that the json_schema is either ignored or causes an error.

Expected Behavior:

The json_schema parameter should be passed to the custom model and enforce the specified JSON output structure, consistent with OpenAI's API behavior (e.g., OpenAI's JSON mode).

Actual Behavior:

The parameter is not forwarded to the model.

If included, the schema may be stripped or result in an error.

Environment:

Dify version: [e.g., 0.15.2]

Deployment: [e.g., Docker, Kubernetes, Bare Metal]

2. Additional context or comments

This feature is particularly important for applications requiring strict JSON output, such as tool calls, APIs, or data pipelines. Without it, post-processing becomes necessary, which adds complexity.

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @liguoxun001 on GitHub (Apr 15, 2025). ### Self Checks - [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. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. ### Description: When using the OpenAI-API-compatible feature to add a custom model, I found that the json_schema parameter (used for response format control, e.g., response_format={ "type": "json_object", "schema": {...} }) cannot be passed through the API request. This limits the ability to enforce structured JSON output from the custom model, which is a critical feature for many use cases. ### Steps to Reproduce: 1. Add a custom model via the OpenAI-API-compatible interface. 2. Attempt to make a request with response_format or json_schema in the payload, e.g.: `{ "model": "custom-model-name", "messages": [...], "response_format": { "type": "json_object", "schema": { "type": "object", "properties": {...} } } }` 3. Observe that the json_schema is either ignored or causes an error. ### Expected Behavior: The json_schema parameter should be passed to the custom model and enforce the specified JSON output structure, consistent with OpenAI's API behavior (e.g., [OpenAI's JSON mode](https://platform.openai.com/docs/guides/text-generation/json-mode)). ### Actual Behavior: The parameter is not forwarded to the model. If included, the schema may be stripped or result in an error. ### Environment: Dify version: [e.g., 0.15.2] Deployment: [e.g., Docker, Kubernetes, Bare Metal] ### 2. Additional context or comments This feature is particularly important for applications requiring strict JSON output, such as tool calls, APIs, or data pipelines. Without it, post-processing becomes necessary, which adds complexity. ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo closed this issue 2026-02-16 10:18:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 15, 2025):

Hello @liguoxun001! I'm Dosu, a bot here to help you with bugs, answer your questions, and assist you in becoming a contributor. I'm ready to support you while you wait for a human maintainer!

I found a similar unsolved discussion titled Support for OpenAI Structured Outputs, which might be relevant to your issue [1]. Additionally, there was a closed issue titled Feature request: support structured outputs for o3-mini and other openai reasoning models, but no solution was found in the comments [2].

To pass the json_schema parameter in an OpenAI-API-compatible custom model, ensure you are using a model that supports JSON Schema, such as gpt-4o-mini-2024-07-18 or later. Enable the JSON Schema option in your application settings and set the response_format field to json_schema. Define a JSON Schema template specifying the output structure, and set strict to true to enforce the schema [3][4].

If you encounter errors related to JSON Schema, upgrading the OpenAI plugin to the latest version and reconfiguring the plugin settings may resolve the issue [5].

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 (Apr 15, 2025): <!-- Greeting --> Hello @liguoxun001! I'm [Dosu](https://dosu.dev), a bot here to help you with bugs, answer your questions, and assist you in becoming a contributor. I'm ready to support you while you wait for a human maintainer! <!-- Answer --> I found a similar unsolved discussion titled [Support for OpenAI Structured Outputs](https://github.com/langgenius/dify/discussions/7170), which might be relevant to your issue <sup>[[1]](https://github.com/langgenius/dify/discussions/7170)</sup>. Additionally, there was a closed issue titled [Feature request: support `structured outputs` for `o3-mini` and other openai reasoning models](https://github.com/langgenius/dify/issues/14350), but no solution was found in the comments <sup>[[2]](https://github.com/langgenius/dify/issues/14350)</sup>. To pass the `json_schema` parameter in an OpenAI-API-compatible custom model, ensure you are using a model that supports JSON Schema, such as `gpt-4o-mini-2024-07-18` or later. Enable the `JSON Schema` option in your application settings and set the `response_format` field to `json_schema`. Define a JSON Schema template specifying the output structure, and set `strict` to `true` to enforce the schema <sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/learn-more/extended-reading/how-to-use-json-schema-in-dify.md)</sup><sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/en/learn-more/how-to-use-json-schema-in-dify.md)</sup>. If you encounter errors related to JSON Schema, upgrading the OpenAI plugin to the latest version and reconfiguring the plugin settings may resolve the issue <sup>[[5]](https://github.com/langgenius/dify/issues/14475)</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/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/33c8ca94-df1d-4761-8e92-c4ff040b44e1?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#198