Questions Regarding the Use of Dify’s API Calling Functionality #12919

Closed
opened 2026-02-21 19:09:40 -05:00 by yindo · 3 comments
Owner

Originally created by @SolomonHoo on GitHub (Apr 14, 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

0.15.3

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Recently, I have been using Dify’s API to call the AI, but I encountered some issues:

  1. I have created a knowledge base and linked it to my AI Agent. When using the API, do I need to specify the knowledge base ID again?
  2. For the same question, if I use Dify’s AI web interface, it returns a response that meets expectations. However, when calling via the API (after clicking “Publish” and ensuring the Agent is up to date), the response is completely different and incorrect. Does this indicate that the API-based interaction is less mature than using the web interface directly?
  3. Regarding question 2, what could be the possible reasons for this discrepancy? How can I improve it?

✔️ Expected Behavior

The results from Dify’s web interface are accurate and meet expectations.

Actual Behavior

However, when using the API to call the same question, the responses are incorrect and show no sign of improvement.

Originally created by @SolomonHoo on GitHub (Apr 14, 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 0.15.3 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce Recently, I have been using Dify’s API to call the AI, but I encountered some issues: 1. I have created a knowledge base and linked it to my AI Agent. When using the API, do I need to specify the knowledge base ID again? 2. For the same question, if I use Dify’s AI web interface, it returns a response that meets expectations. However, when calling via the API (after clicking “Publish” and ensuring the Agent is up to date), the response is completely different and incorrect. Does this indicate that the API-based interaction is less mature than using the web interface directly? 3. Regarding question 2, what could be the possible reasons for this discrepancy? How can I improve it? ### ✔️ Expected Behavior The results from Dify’s web interface are accurate and meet expectations. ### ❌ Actual Behavior However, when using the API to call the same question, the responses are incorrect and show no sign of improvement.
yindo added the 🙋‍♂️ question label 2026-02-21 19:09:40 -05:00
yindo closed this issue 2026-02-21 19:09:40 -05:00
Author
Owner

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

Hello @SolomonHoo! I'm Dosu, a friendly bot here to assist you with bugs, questions, and to help you become a contributor. I'm here to help while you wait for a human maintainer. How can I assist you today?

I found a similar unsolved discussion titled "DIY API interface call, unable to parse context" which might be relevant to your issue [1].

Regarding your questions:

  1. Knowledge Base ID: When using the API, you typically need to specify the knowledge base ID to ensure the AI Agent uses the correct context. This might be necessary even if you've linked it in the web interface.

  2. Response Discrepancy: Differences in responses between the web interface and API calls can occur due to various factors, such as different default settings or parameters. To ensure consistency, you can adjust API parameters like TEMPERATURE, TOP_P, TOP_K, PRESENCE_PENALTY, FREQUENCY_PENALTY, MAX_TOKENS, RESPONSE_FORMAT, and JSON_SCHEMA to match those used in the web interface [2].

  3. Improving Consistency: To improve consistency, ensure that the API parameters are aligned with those used in the web interface. Additionally, verify that the knowledge base is correctly linked and that the AI Agent is up to date after publishing. If discrepancies persist, it might be due to known limitations or issues with the API, such as configuration errors or provider-related issues [3][4].

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 14, 2025): <!-- Greeting --> Hello @SolomonHoo! I'm [Dosu](https://dosu.dev), a friendly bot here to assist you with bugs, questions, and to help you become a contributor. I'm here to help while you wait for a human maintainer. How can I assist you today? <!-- Answer --> I found a similar unsolved discussion titled "[DIY API interface call, unable to parse context](https://github.com/langgenius/dify/discussions/10044)" which might be relevant to your issue <sup>[[1]](https://github.com/langgenius/dify/discussions/10044)</sup>. Regarding your questions: 1. **Knowledge Base ID**: When using the API, you typically need to specify the knowledge base ID to ensure the AI Agent uses the correct context. This might be necessary even if you've linked it in the web interface. 2. **Response Discrepancy**: Differences in responses between the web interface and API calls can occur due to various factors, such as different default settings or parameters. To ensure consistency, you can adjust API parameters like `TEMPERATURE`, `TOP_P`, `TOP_K`, `PRESENCE_PENALTY`, `FREQUENCY_PENALTY`, `MAX_TOKENS`, `RESPONSE_FORMAT`, and `JSON_SCHEMA` to match those used in the web interface <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/entities/defaults.py)</sup>. 3. **Improving Consistency**: To improve consistency, ensure that the API parameters are aligned with those used in the web interface. Additionally, verify that the knowledge base is correctly linked and that the AI Agent is up to date after publishing. If discrepancies persist, it might be due to known limitations or issues with the API, such as configuration errors or provider-related issues <sup>[[3]](https://github.com/langgenius/dify/issues/14215)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/controllers/web/error.py)</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/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c101ac98-a164-4e80-bfcf-0c43274ff91a?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Apr 14, 2025):

This is only for bug report, if you would like to ask a question, please head to Discussions.

@crazywoola commented on GitHub (Apr 14, 2025): 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).
Author
Owner

@crazywoola commented on GitHub (Apr 15, 2025):

  1. No
  2. The logic behind each other should be the same,.
  3. See the bot's reply.
@crazywoola commented on GitHub (Apr 15, 2025): 1. No 2. The logic behind each other should be the same,. 3. See the bot's reply.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12919