Skip to content

credit

Pydantic models for the org-level credit ledger.

Credits live on the organization as an append-only ledger (CreditEntry) with cached balances per wallet (OrgCredits). Research analyses are paid from grants (CreditGrant); commercial analyses and storage above the free ceiling from purchased credits. A credit held for an analysis still running counts in its wallet's held until the analysis ends.

CreditEntry pydantic-model

Bases: BaseModel

A single append-only credit ledger entry on an organization.

Config:

  • from_attributes: True
  • frozen: True

Fields:

bucket pydantic-field

Which credit pool the entry affects

created_at pydantic-field

Creation timestamp

delta pydantic-field

Signed change in credits (positive = grant, negative = charge)

expires_at = None pydantic-field

When the credits granted by this entry expire, for the retired allowance; null otherwise. A grant's expiry is on the grant.

grant_id = None pydantic-field

The grant this entry moves, for entries in the grants bucket; null otherwise.

id pydantic-field

Unique identifier of the ledger entry

note = None pydantic-field

Free-text context recorded with the entry — for admin adjustments, the reason the administrator gave. None for entries created by automatic flows or predating the field.

org_id pydantic-field

The organization this entry belongs to

reason pydantic-field

Why this entry was created

CreditGrant pydantic-model

Bases: BaseModel

One grant of research credits to an organization.

Config:

  • from_attributes: True
  • frozen: True

Fields:

amount pydantic-field

Credits granted.

created_at pydantic-field

When the grant was made.

expires_at = None pydantic-field

When what remains of the grant expires, extensions included; null for a grant that never expires.

id pydantic-field

Unique identifier of the grant.

origin pydantic-field

How the grant came about.

remaining pydantic-field

Credits of the grant not yet spent or expired, held ones included.

request_id = None pydantic-field

The request the grant was approved from, if any.

CreditLedgerPage pydantic-model

Bases: BaseModel

One page of an organization's credit ledger, newest first.

Config:

  • frozen: True

Fields:

entries pydantic-field

The ledger entries in this page, newest first.

total pydantic-field

Total number of ledger entries for the organization.

OrgCredits pydantic-model

Bases: BaseModel

An organization's credits: research grants and purchased credits.

The two never mix. Research analyses are paid from grants; commercial analyses and storage above the free ceiling from purchased.

Config:

  • from_attributes: True
  • frozen: True

Fields:

grants pydantic-field

Credits granted for research analyses, across every grant.

purchased pydantic-field

Credits bought, for commercial analyses and for storage above the free ceiling. They never expire.

WalletBalance pydantic-model

Bases: BaseModel

One of an organization's two credit balances.

Config:

  • from_attributes: True
  • frozen: True

Fields:

available property

Credits a new analysis may use: the balance less what is held.

balance = 0 pydantic-field

Credits in the wallet, held ones included.

held = 0 pydantic-field

Credits held for analyses of this wallet that are still running; charged or released when each ends.