UsageEvent
@forge/monorepo / backend/src / UsageEvent
Type Alias: UsageEvent
UsageEvent =
object
Defined in: backend/src/usage/index.ts:12
Properties
audioSeconds?
readonlyoptionalaudioSeconds?:number
Defined in: backend/src/usage/index.ts:53
cachedInputTokens
readonlycachedInputTokens:number
Defined in: backend/src/usage/index.ts:36
cacheWriteTokens?
readonlyoptionalcacheWriteTokens?:number
Defined in: backend/src/usage/index.ts:44
Tokens written into a prompt cache — task #247.
Optional, and absent means "not reported" rather than "none": rows written before this existed and a turn
whose provider reports no breakdown are different facts, and a zero would merge them. The same rule
imageCount follows.
conversationId?
readonlyoptionalconversationId?:ConversationId
Defined in: backend/src/usage/index.ts:29
costMinorUnits
readonlycostMinorUnits:number
Defined in: backend/src/usage/index.ts:55
Integer minor units in the tenant's accounting currency.
currency
readonlycurrency:string
Defined in: backend/src/usage/index.ts:56
id
readonlyid:string
Defined in: backend/src/usage/index.ts:13
imageCount?
readonlyoptionalimageCount?:number
Defined in: backend/src/usage/index.ts:52
Non-text input this turn carried — #185 AC-4.
Absent means "not counted", not "none". A row written before the count existed and a genuinely text-only turn are different facts, and a zero would merge them.
inputTokens
readonlyinputTokens:number
Defined in: backend/src/usage/index.ts:34
modelId
readonlymodelId:string
Defined in: backend/src/usage/index.ts:33
occurredAt
readonlyoccurredAt:string
Defined in: backend/src/usage/index.ts:57
outputTokens
readonlyoutputTokens:number
Defined in: backend/src/usage/index.ts:35
principalId?
readonlyoptionalprincipalId?:PrincipalId
Defined in: backend/src/usage/index.ts:28
Who consumed it — #175.
A usage record carried a tenant and no principal, so "what has this person spent" was unanswerable: the data was never recorded. Per-user metrics and per-user limits both start here.
Stamped by the recorder from the trusted context, never from the event payload — the same rule tenantId
follows, and for the same reason: a caller that could name the principal on a usage event could bill someone
else's budget.
Optional on the type, because rows written before this exist and a record with an unknown principal is a fact rather than a thing to invent. It is nullable in storage for that reason too.
reasoningTokens?
readonlyoptionalreasoningTokens?:number
Defined in: backend/src/usage/index.ts:45
runId
readonlyrunId:RunId
Defined in: backend/src/usage/index.ts:30
stepId?
readonlyoptionalstepId?:string
Defined in: backend/src/usage/index.ts:31
tenantId
readonlytenantId:string
Defined in: backend/src/usage/index.ts:14
toolCallId?
readonlyoptionaltoolCallId?:string
Defined in: backend/src/usage/index.ts:32