Skip to content

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


Signature

declare const UsageDoc: State.ConversationDefinition<any>

Source

Since v0.0.0

Signature

declare const UsageState: any

Source

Since v0.0.0

Signature

type UsageState = typeof UsageState.Type

Source

Since v0.0.0

The sum of two usages.

Signature

declare const add: (total: Usage, usage: Usage) => Usage

Source

Since v0.0.0

The committed ledger of a conversation; empty when absent.

Signature

declare const get: (conversationId: ConversationId) => Effect.Effect<UsageState, unknown, Session>

Source

Since v0.0.0

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) => any

Source

Since v0.0.0