Usage
The built-in usage ledger of a conversation (pi.usage): its own spend, by model and by tool. Every writer of an
assistant entry or a tool result with usage adds it in the same commit. A fork starts at zero.
Since v0.0.0
UsageDoc
Section titled “UsageDoc”Signature
declare const UsageDoc: State.ConversationDefinition<any>Since v0.0.0
UsageState
Section titled “UsageState”Signature
declare const UsageState: anySince v0.0.0
UsageState (type alias)
Section titled “UsageState (type alias)”Signature
type UsageState = typeof UsageState.TypeSince v0.0.0
The sum of two usages.
Signature
declare const add: (total: Usage, usage: Usage) => UsageSince v0.0.0
The committed ledger of a conversation; empty when absent.
Signature
declare const get: (conversationId: ConversationId) => Effect.Effect<UsageState, unknown, Session>Since v0.0.0
record
Section titled “record”Add usage to one bucket of the conversation’s ledger, in the current transaction.
Signature
declare const record: (conversationId: ConversationId, bucket: keyof UsageState, key: string, usage: Usage) => anySince v0.0.0