record_usage
Record actual token usage for a completed LLM call. Cost is computed server-side from current pricing, never trusted from the caller — this is the 'actual spend' counterpart to estimate_cost's hypothetical numbers. Optionally scope to an org_id for per-org spend tracking. Resubmitting the same request_id for the same org is a no-op. Use when the user wants to log or track real LLM spend, not just estimate it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| org_id | No | Optional organisation ID to attribute this usage to | |
| model_name | Yes | Name of the LLM model that was called | |
| request_id | No | Optional idempotency key — resubmitting the same value is a no-op | |
| session_id | No | Optional session ID to tag this event with, so it can later be grouped and retrieved via analyze_session_usage — e.g. a bounded burst of calls like a coding-agent run or a chat session | |
| occurred_at | No | Unix timestamp when the call happened (default: now) | |
| input_tokens | Yes | Number of input tokens actually used | |
| output_tokens | Yes | Number of output tokens actually used |