Custom model following OpenAI-API-compatible format cannot be parsed correctly in Dify #461

Closed
opened 2026-02-16 10:19:28 -05:00 by yindo · 3 comments
Owner

Originally created by @niudehua on GitHub (Jul 18, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.6

Cloud or Self Hosted

Cloud

Steps to reproduce

I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this:

{
  "id": "6b2802a3-1365-457e-b015-4eac9aae5feb",
  "object": "chat.completion",
  "created": 1752825256,
  "model": "@cf/qwen/qwen2.5-coder-32b-instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?"
      },
      "finish_reason": "stop"
    }
  ]
}

However, Dify's result returns as:

{
  "text": "",
  "usage": {
    "prompt_tokens": 462,
    "prompt_unit_price": "0",
    "prompt_price_unit": "0",
    "prompt_price": "0",
    "completion_tokens": 0,
    "completion_unit_price": "0",
    "completion_price_unit": "0",
    "completion_price": "0",
    "total_tokens": 462,
    "total_price": "0",
    "currency": "USD",
    "latency": 7.905867327004671
  },
  "finish_reason": "stop",
  "files": []
}

It seems Dify does not correctly parse the result or choices.message.content from the response.

Could you please help to confirm if this is a bug or if additional configuration is needed?

Image

✔️ Expected Behavior

I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this:

{
  "id": "6b2802a3-1365-457e-b015-4eac9aae5feb",
  "object": "chat.completion",
  "created": 1752825256,
  "model": "@cf/qwen/qwen2.5-coder-32b-instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?"
      },
      "finish_reason": "stop"
    }
  ]
}

However, Dify's result returns as:

{
  "text": "",
  "usage": {
    "prompt_tokens": 462,
    "prompt_unit_price": "0",
    "prompt_price_unit": "0",
    "prompt_price": "0",
    "completion_tokens": 0,
    "completion_unit_price": "0",
    "completion_price_unit": "0",
    "completion_price": "0",
    "total_tokens": 462,
    "total_price": "0",
    "currency": "USD",
    "latency": 7.905867327004671
  },
  "finish_reason": "stop",
  "files": []
}

It seems Dify does not correctly parse the result or choices.message.content from the response.

Could you please help to confirm if this is a bug or if additional configuration is needed?

Image

Actual Behavior

I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this:

{
  "id": "6b2802a3-1365-457e-b015-4eac9aae5feb",
  "object": "chat.completion",
  "created": 1752825256,
  "model": "@cf/qwen/qwen2.5-coder-32b-instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?"
      },
      "finish_reason": "stop"
    }
  ]
}

However, Dify's result returns as:

{
  "text": "",
  "usage": {
    "prompt_tokens": 462,
    "prompt_unit_price": "0",
    "prompt_price_unit": "0",
    "prompt_price": "0",
    "completion_tokens": 0,
    "completion_unit_price": "0",
    "completion_price_unit": "0",
    "completion_price": "0",
    "total_tokens": 462,
    "total_price": "0",
    "currency": "USD",
    "latency": 7.905867327004671
  },
  "finish_reason": "stop",
  "files": []
}

It seems Dify does not correctly parse the result or choices.message.content from the response.

Could you please help to confirm if this is a bug or if additional configuration is needed?

Image
Originally created by @niudehua on GitHub (Jul 18, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.6 ### Cloud or Self Hosted Cloud ### Steps to reproduce I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this: ```json { "id": "6b2802a3-1365-457e-b015-4eac9aae5feb", "object": "chat.completion", "created": 1752825256, "model": "@cf/qwen/qwen2.5-coder-32b-instruct", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?" }, "finish_reason": "stop" } ] } ``` However, Dify's result returns as: ```json { "text": "", "usage": { "prompt_tokens": 462, "prompt_unit_price": "0", "prompt_price_unit": "0", "prompt_price": "0", "completion_tokens": 0, "completion_unit_price": "0", "completion_price_unit": "0", "completion_price": "0", "total_tokens": 462, "total_price": "0", "currency": "USD", "latency": 7.905867327004671 }, "finish_reason": "stop", "files": [] } ``` It seems Dify does not correctly parse the `result` or `choices.message.content` from the response. Could you please help to confirm if this is a bug or if additional configuration is needed? <img width="1412" height="1027" alt="Image" src="https://github.com/user-attachments/assets/9b708ebe-06a4-4406-81d4-93371d947e50" /> ### ✔️ Expected Behavior I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this: ```json { "id": "6b2802a3-1365-457e-b015-4eac9aae5feb", "object": "chat.completion", "created": 1752825256, "model": "@cf/qwen/qwen2.5-coder-32b-instruct", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?" }, "finish_reason": "stop" } ] } ``` However, Dify's result returns as: ```json { "text": "", "usage": { "prompt_tokens": 462, "prompt_unit_price": "0", "prompt_price_unit": "0", "prompt_price": "0", "completion_tokens": 0, "completion_unit_price": "0", "completion_price_unit": "0", "completion_price": "0", "total_tokens": 462, "total_price": "0", "currency": "USD", "latency": 7.905867327004671 }, "finish_reason": "stop", "files": [] } ``` It seems Dify does not correctly parse the `result` or `choices.message.content` from the response. Could you please help to confirm if this is a bug or if additional configuration is needed? <img width="1412" height="1027" alt="Image" src="https://github.com/user-attachments/assets/9b708ebe-06a4-4406-81d4-93371d947e50" /> ### ❌ Actual Behavior I configured a custom model under the "OpenAI-API-compatible" type, following the OpenAI chat completion response format like this: ```json { "id": "6b2802a3-1365-457e-b015-4eac9aae5feb", "object": "chat.completion", "created": 1752825256, "model": "@cf/qwen/qwen2.5-coder-32b-instruct", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "It looks like you entered some characters that might not be fully visible or recognized. Could you please clarify or provide more context so I can assist you better?" }, "finish_reason": "stop" } ] } ``` However, Dify's result returns as: ```json { "text": "", "usage": { "prompt_tokens": 462, "prompt_unit_price": "0", "prompt_price_unit": "0", "prompt_price": "0", "completion_tokens": 0, "completion_unit_price": "0", "completion_price_unit": "0", "completion_price": "0", "total_tokens": 462, "total_price": "0", "currency": "USD", "latency": 7.905867327004671 }, "finish_reason": "stop", "files": [] } ``` It seems Dify does not correctly parse the `result` or `choices.message.content` from the response. Could you please help to confirm if this is a bug or if additional configuration is needed? <img width="1412" height="1027" alt="Image" src="https://github.com/user-attachments/assets/9b708ebe-06a4-4406-81d4-93371d947e50" />
yindo closed this issue 2026-02-16 10:19:28 -05:00
Author
Owner

@crazywoola commented on GitHub (Jul 18, 2025):

Please provide the plugin version as well.

@crazywoola commented on GitHub (Jul 18, 2025): Please provide the plugin version as well.
Author
Owner

@niudehua commented on GitHub (Jul 18, 2025):

Please provide the plugin version as well.

OpenAI-API-compatible
0.0.17

@niudehua commented on GitHub (Jul 18, 2025): > Please provide the plugin version as well. OpenAI-API-compatible 0.0.17
Author
Owner

@dosubot[bot] commented on GitHub (Aug 20, 2025):

Hi, @niudehua. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that in Dify version 1.6 cloud, a custom model using the OpenAI-API-compatible format (plugin version 0.0.17) returns a valid chat completion JSON.
  • Despite the valid JSON, Dify fails to parse it correctly, resulting in an empty "text" field and zero completion tokens.
  • The issue seems related to response parsing specific to this plugin version.
  • The maintainer requested and you provided the plugin version for further investigation.
  • The issue remains unresolved with no recent updates.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here.
  • If no response is received within 5 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 20, 2025): Hi, @niudehua. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that in Dify version 1.6 cloud, a custom model using the OpenAI-API-compatible format (plugin version 0.0.17) returns a valid chat completion JSON. - Despite the valid JSON, Dify fails to parse it correctly, resulting in an empty "text" field and zero completion tokens. - The issue seems related to response parsing specific to this plugin version. - The maintainer requested and you provided the plugin version for further investigation. - The issue remains unresolved with no recent updates. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of the dify-official-plugins repository by commenting here. - If no response is received within 5 days, I will automatically close this issue. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#461