mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Unable to pass json_schema parameter in OpenAI-API-compatible custom model #198
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @liguoxun001 on GitHub (Apr 15, 2025).
Self Checks
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:
Add a custom model via the OpenAI-API-compatible interface.
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": {...} } } }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?
@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 outputsforo3-miniand other openai reasoning models, but no solution was found in the comments [2].To pass the
json_schemaparameter in an OpenAI-API-compatible custom model, ensure you are using a model that supports JSON Schema, such asgpt-4o-mini-2024-07-18or later. Enable theJSON Schemaoption in your application settings and set theresponse_formatfield tojson_schema. Define a JSON Schema template specifying the output structure, and setstricttotrueto 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