Repository navigation
Replies: 3 comments 1 reply
|
Hi @Joy-0403! I'm Dosu and I'm helping the Dify team. Dify gives you partial cost visibility. I found nothing for a per-run budget, a budget alert or a cost-based fallback to a cheaper model. Token usage and price are tracked per LLM call. Classic agent runners sum usage across iteration rounds, and workflow agent nodes persist it on the node execution record [1]. The App Overview page has token and cost charts for chat, completion and workflow apps. It plots token count, with an approximate dollar amount in the tooltip when the API provides it [2]. That is daily, per-app granularity, not per-run. For per-run or per-node detail, Dify's ops-trace pipeline can send traces to Langfuse, LangSmith, Phoenix and others [3]. In Langfuse, each LLM node in a workflow becomes its own generation with token and cost fields [1]. That is the closest answer to "where did the $10 go". Retry and loop cost would show up as additional generations or spans in the trace. The numbers have some gaps:
For runaway agents, there are global guards on workflow executions: For a budget cap today, the usual workaround is to export traces to Langfuse and alert on cost there. You can also build it inside a workflow: use a conditional branch on accumulated tokens, with an iteration or loop limit, to route to a cheaper model. To reply, just mention @dosu. Docs are dead. Just use Dosu. |
|
@Joy-0403 one option from outside Dify, with an honest limit up front. I maintain Inferrail (open source), a local gateway that sits between an app and the model provider, so weigh this accordingly. Point Dify's "OpenAI-API-compatible" model provider at the gateway (
The limit: a budget per run needs each request to carry a run id. The gateway does that with a header ( I haven't run this against a Dify instance myself. The gateway side (receipts, daily cap, refusal before the provider) is what I've tested with other OpenAI-compatible clients. |
|
@Joy-0403 Exactly—that’s why I wouldn’t treat a provider-level headers field as sufficient. The run ID needs to be attached at the workflow/model boundary and carried through retries and parallel branches. A static provider header identifies provider config, not a specific execution. With request-scoped propagation, the gateway can reserve against one budget keyed by the root Without that propagation, a gateway can provide per-call or daily accounting, but not a true per-run cap. |
Uh oh!
There was an error while loading. Please reload this page.
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
Some agent runs end up costing $10+ and I’m trying to figure out where the money actually goes. Is there a good way to break cost down by workflow, see how much retries are costing, or catch an agent that’s stuck in a slow loop? Would also be great to set a budget per run — alert when it’s close to the limit, or automatically fall back to a cheaper model.
2. Additional context or comments
No response
All reactions