After adding the model, the model cost has always been 0 #6536

Closed
opened 2026-02-21 18:16:11 -05:00 by yindo · 10 comments
Owner

Originally created by @luca1024-web on GitHub (Nov 4, 2024).

Originally assigned to: @ZhouhaoJiang on GitHub.

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.10.2

Cloud or Self Hosted

Cloud

Steps to reproduce

I'm using langfuse to monitor one of dify's applications
Traces can be monitored, total_tokens is also there
The model I'm using is ollama's Doubao-pro-32k, configured it on the page, but it doesn't work
image
image
image

(langfuse : 2.86.0
dify: 0.10.2
ollama: Doubao-pro-32k-functioncall-240815)

Of course, I also tested it in the integrated gpt-4o-mini and the results were the same
I just want to monitor TOTAL COST, am I misconfiguring it or is it a bug?
Thanks, looking forward to your reply!

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @luca1024-web on GitHub (Nov 4, 2024). Originally assigned to: @ZhouhaoJiang on GitHub. ### 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.10.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce I'm using langfuse to monitor one of dify's applications Traces can be monitored, total_tokens is also there The model I'm using is ollama's Doubao-pro-32k, configured it on the page, but it doesn't work ![image](https://github.com/user-attachments/assets/e3ac41ee-47f8-451f-a0ee-ceec730f1b96) ![image](https://github.com/user-attachments/assets/b1f5024f-2c74-44c6-907c-cdf478ebc562) ![image](https://github.com/user-attachments/assets/533c36d6-f3ca-4d3f-85b4-d82bdf301952) **(langfuse : 2.86.0 dify: 0.10.2 ollama: Doubao-pro-32k-functioncall-240815)** Of course, I also tested it in the integrated gpt-4o-mini and the results were the same I just want to monitor TOTAL COST, am I misconfiguring it or is it a bug? Thanks, looking forward to your reply! ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:16:11 -05:00
yindo closed this issue 2026-02-21 18:16:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 4, 2024):

Hey @luca1024-web! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together!

I found a similar unsolved discussion regarding custom model costs in Dify, which might be related to your issue. You can check it out here: Custom Model costs [1].

Regarding your issue with the model cost always being 0, there might be a few areas to investigate:

  1. Configuration Settings: Ensure that the configuration for the custom model, ollama's Doubao-pro-32k, is correctly set up. This includes the model name, base URL, model type, context length, and maximum token limit. Double-check these settings against the requirements for integrating custom models in Dify [2].

  2. Langfuse Integration: Since you're using Langfuse for monitoring, verify that the integration is correctly set up and that it supports cost tracking. Langfuse is used for monitoring application performance and costs, so any misconfiguration here might affect cost tracking [3].

  3. Known Issues: There might be known issues or limitations with cost tracking in Dify version 0.10.2 that haven't been documented yet. It could be beneficial to keep an eye on updates or discussions in the Dify community for any related bug reports or fixes.

If these steps don't resolve the issue, it might be worth considering whether this is a bug in the current version of Dify, especially since you've tested with different models and configurations.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 4, 2024): <!-- Greeting --> Hey @luca1024-web! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together! <!-- Answer --> I found a similar unsolved discussion regarding custom model costs in Dify, which might be related to your issue. You can check it out here: [Custom Model costs](https://github.com/langgenius/dify/discussions/8359) <sup>[[1]](https://github.com/langgenius/dify/discussions/8359)</sup>. Regarding your issue with the model cost always being 0, there might be a few areas to investigate: 1. **Configuration Settings**: Ensure that the configuration for the custom model, ollama's Doubao-pro-32k, is correctly set up. This includes the model name, base URL, model type, context length, and maximum token limit. Double-check these settings against the requirements for integrating custom models in Dify <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/ollama/ollama.yaml)</sup>. 2. **Langfuse Integration**: Since you're using Langfuse for monitoring, verify that the integration is correctly set up and that it supports cost tracking. Langfuse is used for monitoring application performance and costs, so any misconfiguration here might affect cost tracking <sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/monitoring/integrate-external-ops-tools/README.md)</sup>. 3. **Known Issues**: There might be known issues or limitations with cost tracking in Dify version 0.10.2 that haven't been documented yet. It could be beneficial to keep an eye on updates or discussions in the Dify community for any related bug reports or fixes. If these steps don't resolve the issue, it might be worth considering whether this is a bug in the current version of Dify, especially since you've tested with different models and configurations. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@luca1024-web commented on GitHub (Nov 4, 2024):

image
image
image
As shown in the figure above, I created a test to verify the integrated 4o-mini model. The token count is correctly counted and the cost is still 0.

@luca1024-web commented on GitHub (Nov 4, 2024): ![image](https://github.com/user-attachments/assets/098a36bb-0821-498f-9e4f-939eb68a1a73) ![image](https://github.com/user-attachments/assets/8d761ad4-57f5-4d8d-a757-7b7889094836) ![image](https://github.com/user-attachments/assets/19b7d45a-a968-4d6b-b60e-c24d527a9a1c) As shown in the figure above, I created a test to verify the integrated 4o-mini model. The token count is correctly counted and the cost is still 0.
Author
Owner

@ZhouhaoJiang commented on GitHub (Nov 5, 2024):

CleanShot 2024-11-05 at 15 58 11@2x

CleanShot 2024-11-05 at 15 57 49@2x

Hello, I have tested it again, and there is no problem with langfuse for model cost tracking.

@ZhouhaoJiang commented on GitHub (Nov 5, 2024): ![CleanShot 2024-11-05 at 15 58 11@2x](https://github.com/user-attachments/assets/3b1cca3e-54b1-4691-9777-27b24edc7cf7) ![CleanShot 2024-11-05 at 15 57 49@2x](https://github.com/user-attachments/assets/d911b377-de20-46bd-9dca-55682fc682fb) Hello, I have tested it again, and there is no problem with langfuse for model cost tracking.
Author
Owner

@luca1024-web commented on GitHub (Nov 5, 2024):

CleanShot 2024-11-05 at 15 58 11@2x

CleanShot 2024-11-05 at 15 57 49@2x

Hello, I have tested it again, and there is no problem with langfuse for model cost tracking.

Both dify and langfuse are built with k8s, and both use external postgreSQL. In addition, my langfuse version is 2.86.0. I can provide you with any data you need to know. Can you help me analyze where the problem is? Thank you for your reply

@luca1024-web commented on GitHub (Nov 5, 2024): > ![CleanShot 2024-11-05 at 15 58 11@2x](https://private-user-images.githubusercontent.com/79627742/383055261-3b1cca3e-54b1-4691-9777-27b24edc7cf7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzA3OTk1OTAsIm5iZiI6MTczMDc5OTI5MCwicGF0aCI6Ii83OTYyNzc0Mi8zODMwNTUyNjEtM2IxY2NhM2UtNTRiMS00NjkxLTk3NzctMjdiMjRlZGM3Y2Y3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDExMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMTA1VDA5MzQ1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAxMzBlNmVmMWJhNWRjMWJkN2Y4YjIwNWFmYjRiZmM4M2E1YzQ5YWFjYWRiNDMwNGQyODRhZGViZTQ0MWZlYmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WpEDamxn2fdYkfGOPfSwCfDI5d4QPOVV6x3kFkAbHgI) > > ![CleanShot 2024-11-05 at 15 57 49@2x](https://private-user-images.githubusercontent.com/79627742/383055166-d911b377-de20-46bd-9dca-55682fc682fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzA3OTk1OTAsIm5iZiI6MTczMDc5OTI5MCwicGF0aCI6Ii83OTYyNzc0Mi8zODMwNTUxNjYtZDkxMWIzNzctZGUyMC00NmJkLTlkY2EtNTU2ODJmYzY4MmZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDExMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMTA1VDA5MzQ1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJjYTk4NDUwM2FhNWJlN2E5NDQ5Yzg5ODY4NDYyZDYzY2IyYWVhMzM1OGJmOTlkYWI5N2JhMjM3NjljYTU5MTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.k0MzvB4bYFP2jqXfV6vLs_PmQsDluceler2s5icemQk) > > Hello, I have tested it again, and there is no problem with langfuse for model cost tracking. Both dify and langfuse are built with k8s, and both use external postgreSQL. In addition, my langfuse version is 2.86.0. I can provide you with any data you need to know. Can you help me analyze where the problem is? Thank you for your reply
Author
Owner

@luca1024-web commented on GitHub (Nov 6, 2024):

@ZhouhaoJiang
4fa646be-d60f-41ee-8907-8271e3cff37a
As shown in the figure above, I found a case where I queried an external database

I tried the following operations and found that the values ​​of input_cost, output_cost, and total_cost were all null. My PostgreSQL version is 13. Is this correct?
image

@luca1024-web commented on GitHub (Nov 6, 2024): @ZhouhaoJiang ![4fa646be-d60f-41ee-8907-8271e3cff37a](https://github.com/user-attachments/assets/37b8e0f8-4650-498d-a225-e971ae316687) As shown in the figure above, I found a case where I queried an external database I tried the following operations and found that the values ​​of input_cost, output_cost, and total_cost were all null. My PostgreSQL version is 13. Is this correct? ![image](https://github.com/user-attachments/assets/66f897d9-e609-4230-9f52-487e3e5ce43c)
Author
Owner

@ZhouhaoJiang commented on GitHub (Nov 6, 2024):

@luca1024-web Maybe your model doesn't support calculations in Langfuse

@ZhouhaoJiang commented on GitHub (Nov 6, 2024): @luca1024-web Maybe your model doesn't support calculations in Langfuse
Author
Owner

@luca1024-web commented on GitHub (Nov 6, 2024):

@ZhouhaoJiang I don't think so. As I provided a screenshot of the integration of 4o-mini, the token count is correct and the cost is still 0. Langfuse has the ability to customize models. Now neither of them can count the cost. Through the postgreSQL:13 I provided, can you find anything? Or what data can I provide to help you quickly locate the problem and help me?

@luca1024-web commented on GitHub (Nov 6, 2024): @ZhouhaoJiang I don't think so. As I provided a screenshot of the integration of 4o-mini, the token count is correct and the cost is still 0. Langfuse has the ability to customize models. Now neither of them can count the cost. Through the postgreSQL:13 I provided, can you find anything? Or what data can I provide to help you quickly locate the problem and help me?
Author
Owner

@ZhouhaoJiang commented on GitHub (Nov 6, 2024):

@luca1024-web dify's recommended version of the pg database is greater than 14, but I'm not sure if that makes a difference, From the picture, you are not using the Cloud version but the Self Host version, right ?

@ZhouhaoJiang commented on GitHub (Nov 6, 2024): @luca1024-web dify's recommended version of the pg database is greater than 14, but I'm not sure if that makes a difference, From the picture, you are not using the Cloud version but the Self Host version, right ?
Author
Owner

@luca1024-web commented on GitHub (Nov 6, 2024):

@ZhouhaoJiang No, I am using the cloud version of postgreSQL, but the picture shows that I am connecting from an external network through the DBeaver tool. I will try to use version 14 to see if there is any difference. I will give you feedback then. Thanks again for your reply

@luca1024-web commented on GitHub (Nov 6, 2024): @ZhouhaoJiang No, I am using the cloud version of postgreSQL, but the picture shows that I am connecting from an external network through the DBeaver tool. I will try to use version 14 to see if there is any difference. I will give you feedback then. Thanks again for your reply
Author
Owner

@luca1024-web commented on GitHub (Nov 7, 2024):

@ZhouhaoJiang The DB versions of dify and langfuse are both PG14. The problem still exists. The screenshot is of the langfuse DB.
img_v3_02gd_484b347b-c07c-48e1-b600-c808a7f1783g
img_v3_02gd_da5ab2af-c2e1-46b0-b4d8-e7510c75028g

@luca1024-web commented on GitHub (Nov 7, 2024): @ZhouhaoJiang The DB versions of dify and langfuse are both PG14. The problem still exists. The screenshot is of the langfuse DB. ![img_v3_02gd_484b347b-c07c-48e1-b600-c808a7f1783g](https://github.com/user-attachments/assets/e47d3ff1-c16a-4018-83d3-c322c1e825f1) ![img_v3_02gd_da5ab2af-c2e1-46b0-b4d8-e7510c75028g](https://github.com/user-attachments/assets/6327180d-b7ed-4f6c-9e94-a60af6960437)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6536