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.
- Hooks don’t receive cost. In the desktop app,
stopandafterAgentResponsedo include the turn’sinput_tokens,output_tokens,cache_read_tokensandcache_write_tokens(parent agent only, once the turn ends), so nothing is available atbeforeSubmitPrompt. - OpenTelemetry Export (Enterprise) pushes a
cursor.api.requestlog to your collector for each model call, with token counts, model, user andcursor.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. - There’s no built-in per-session limit. The way to build one is a
beforeSubmitPrompthook that looks upconversation_idanduser_emailin your ledger and returnscontinue: falsewith auser_messageonce the budget is spent. - Cloud Agents run the same command hooks, from the repo’s
.cursor/hooks.jsonand from team hooks in the dashboard, includingbeforeSubmitPrompt,preToolUseandstop(sessionStartandsessionEnddon’t run there). Theconversation_idis the agent’sbc-id, and GET /v1/agents/{id}/usage returns tokens per run. - For the monthly per-developer cap, use the built-in member spend limits, which you can also set through the Admin API. 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.