OpenAI-API-compatible Model throws "Non-JSON encountered." error #9569

Closed
opened 2026-02-21 18:36:18 -05:00 by yindo · 0 comments
Owner

Originally created by @TinyFatty on GitHub (Mar 6, 2025).

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

1.0.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I used OpenAI-API-compatible Models (offered by China Telecom) in workflow LLM blocks and it throws "Non-JSON encountered." error (3 blocks share the same configuration, Deepseek official api and Silconflow deepseek api return the correct answer).

Here is the configuration for all

Image

Here is the error message

Image

OUTPUT data:

{
  "text": "",
  "usage": {
    "prompt_tokens": 0,
    "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": 0,
    "total_price": "0",
    "currency": "USD",
    "latency": 0.9801772950013401
  },
  "finish_reason": "Non-JSON encountered."
}

It takes only 1 second and no token is used,so I think the error occurs before the model starts reasoning.
Then I tested this model with python scripts

import openai

client= openai.OpenAI(base_url="***",
                           api_key="***")


response = client.chat.completions.create(
    model="7ba7726dad4c4ea4ab7f39c7741aea68",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who are you?"}
    ],
    temperature=0.7
)

It shows the corrent answer
{"code":0,"id":"chatcmpl-00-89c57718adba43dd5650511e4ecece0f-ba26f79321d736fa-01","choices":[{"index":0,"message":{"content":"<think>\nGreetings! I'm DeepSeek-R1, an artificial intelligence assistant created by DeepSeek. I'm at your service and would be delighted to assist you with any inquiries or tasks you may have.\n</think>\n\nGreetings! I'm DeepSeek-R1, an artificial intelligence assistant created by DeepSeek. I'm at your service and would be delighted to assist you with any inquiries or tasks you may have.","role":"assistant"},"finish_reason":"stop"}],"created":1741254044,"model":"DeepSeek-R1","object":"chat.completion","usage":{"completion_tokens":83,"prompt_tokens":16,"total_tokens":99}}
Is there any special configuration I missed for OpenAI-API-compatible Model?

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @TinyFatty on GitHub (Mar 6, 2025). ### 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 1.0.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I used OpenAI-API-compatible Models (offered by China Telecom) in workflow LLM blocks and it throws "Non-JSON encountered." error (3 blocks share the same configuration, Deepseek official api and Silconflow deepseek api return the correct answer). Here is the configuration for all ![Image](https://github.com/user-attachments/assets/6ec57804-e8f2-4a07-b91d-cacfae723f12) Here is the error message ![Image](https://github.com/user-attachments/assets/a1ec4818-bd12-4e5e-8304-c3971cf8f863) OUTPUT data: ``` { "text": "", "usage": { "prompt_tokens": 0, "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": 0, "total_price": "0", "currency": "USD", "latency": 0.9801772950013401 }, "finish_reason": "Non-JSON encountered." } ``` It takes only 1 second and no token is used,so I think the error occurs before the model starts reasoning. Then I tested this model with python scripts ``` import openai client= openai.OpenAI(base_url="***", api_key="***") response = client.chat.completions.create( model="7ba7726dad4c4ea4ab7f39c7741aea68", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who are you?"} ], temperature=0.7 ) ``` It shows the corrent answer `{"code":0,"id":"chatcmpl-00-89c57718adba43dd5650511e4ecece0f-ba26f79321d736fa-01","choices":[{"index":0,"message":{"content":"<think>\nGreetings! I'm DeepSeek-R1, an artificial intelligence assistant created by DeepSeek. I'm at your service and would be delighted to assist you with any inquiries or tasks you may have.\n</think>\n\nGreetings! I'm DeepSeek-R1, an artificial intelligence assistant created by DeepSeek. I'm at your service and would be delighted to assist you with any inquiries or tasks you may have.","role":"assistant"},"finish_reason":"stop"}],"created":1741254044,"model":"DeepSeek-R1","object":"chat.completion","usage":{"completion_tokens":83,"prompt_tokens":16,"total_tokens":99}}` Is there any special configuration I missed for OpenAI-API-compatible Model? ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:36:18 -05:00
yindo closed this issue 2026-02-21 18:36:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#9569