mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Open Router structured output #317
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 @Rumdaz on GitHub (May 27, 2025).
Self Checks
Dify version
1.4.0
Cloud or Self Hosted
Cloud
Steps to reproduce
When using OpenRouter as the provider, some models that originally support structured_output are unable to correctly select the structured_output feature.
✔️ Expected Behavior
OpenRouter's model can also support structured_output automatically or through manual configuration.
❌ Actual Behavior
No response
@dosubot[bot] commented on GitHub (May 27, 2025):
There is a known issue where some models accessed via OpenRouter in Dify do not correctly enable the structured_output feature, even if the underlying model supports it. A similar problem was previously reported for the
4o-minimodel and was resolved by introducing a workaround for thejson_schemamode, which is one of the structured output formats supported by Dify models. This suggests that structured_output support may depend on both the provider integration and the specific model configuration in Dify, and workarounds or updates may be required for certain models to enable this feature automatically (reference).Dify provides a UI component for configuring structured output, allowing you to manually define a JSON schema for the model's output. If a model does not support structured output natively, Dify will fall back to prompt injection to approximate the desired structure. You can access this configuration in the workflow node settings, where a modal allows you to define or edit the output schema (reference).
If you encounter a model that does not automatically enable structured_output, you can try manually configuring the schema through the UI. However, if the model or provider integration does not support the required response format (such as
json_schema,JSON, orjson_object), structured output may not function as expected, and Dify will downgrade to prompt-based formatting (reference).In summary:
json_schemamode is handled, so future updates to Dify may improve compatibility for more OpenRouter models.If you continue to experience issues, it may be related to the current limitations of the provider integration or the specific model's support for structured output formats.
To reply, just mention my name @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@davyzhang commented on GitHub (Jun 3, 2025):
For open router there's an unified way to specify json_schema
https://openrouter.ai/docs/features/structured-outputs
The problem is that open router is a growing platform, many models will be added over time.
In my case, I manually added gemini flash 2.0 to model list, and there's no json schema format ui, but it absolutely supports structural output.
I think it's better to let the json schema input ui show with a toggle for open router models.
User will have to decide whether enable it or not
@orangeclk commented on GitHub (Jul 2, 2025):
I will follow up on this issue.
@orangeclk commented on GitHub (Jul 4, 2025):
Following up on my PR #1177, which introduced the structured outputs feature.
The implementation is confirmed to work correctly with OpenAI models, but my tests with the Gemini series were unsuccessful.
There appears to be conflicting information from OpenRouter on this:
structured_outputsparameter.This discrepancy suggests the intended behavior for Gemini's structured outputs via OpenRouter is currently undefined or inconsistent. Clarification on this would be helpful.
@dosubot[bot] commented on GitHub (Aug 20, 2025):
Hi, @Rumdaz. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.
Issue Summary:
Next Steps:
Thank you for your understanding and contribution!