# Real-time cost governance using Cursor Hooks

**URL:** <https://forum.cursor.com/t/real-time-cost-governance-using-cursor-hooks/178548>\
**Category:** Help\
**Tags:** organizations, hooks, cloud-agents, teams-enterprise\
**Created:** [November 16, 2026, 2:52pm UTC](https://forum.cursor.com/t/real-time-cost-governance-using-cursor-hooks/178548 "2026-11-16T14:52:09Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [November 16, 2026, 3:17pm UTC](https://forum.cursor.com/t/real-time-cost-governance-using-cursor-hooks/178548/5 "2026-11-16T15:17:01Z")

</div>

Hi @ManvendraSK, there’s no synchronous cost in hooks today, but you can get close to real time by feeding your own ledger from OpenTelemetry Export and checking it in a `beforeSubmitPrompt` hook.

On the gateway idea: there’s no self-serve way to put your own gateway in front of every model request, including Cursor’s managed models and Cloud Agents. If that’s a hard requirement, your account team is the place to raise it.

1. Hooks don’t receive cost. In the desktop app, `stop` and `afterAgentResponse` do include the turn’s `input_tokens`, `output_tokens`, `cache_read_tokens` and `cache_write_tokens` (parent agent only, once the turn ends), so nothing is available at `beforeSubmitPrompt`.
2. [OpenTelemetry Export](https://cursor.com/docs/enterprise/opentelemetry-export) (Enterprise) pushes a `cursor.api.request` log to your collector for each model call, with token counts, model, user and `cursor.conversation.id`, across desktop, CLI and Cloud Agents. Its cost metric is a best-effort estimate per user and model, not per conversation, so session cost means pricing the tokens yourself.
3. There’s no built-in per-session limit. The way to build one is a `beforeSubmitPrompt` hook that looks up `conversation_id` and `user_email` in your ledger and returns `continue: false` with a `user_message` once the budget is spent.
4. Cloud Agents run the same command hooks, from the repo’s `.cursor/hooks.json` and from team hooks in the dashboard, including `beforeSubmitPrompt`, `preToolUse` and `stop` (`sessionStart` and `sessionEnd` don’t run there). The `conversation_id` is the agent’s `bc-` id, and [GET /v1/agents/{id}/usage](https://cursor.com/docs/cloud-agent/api/endpoints#get-agent-usage) returns tokens per run.
5. For the monthly per-developer cap, use the built-in member spend limits, which you can also set through the [Admin API](https://cursor.com/docs/account/teams/admin-api#set-user-spend-limit). Those are enforced on Cursor’s side for desktop and Cloud Agents alike. Daily and weekly windows aren’t built in, so those would live in your ledger.

---

_[View the full topic](https://forum.cursor.com/t/real-time-cost-governance-using-cursor-hooks/178548)._
