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:Truefrozen:True
Fields:
-
id(UUID) -
org_id(UUID) -
bucket(CreditBucket) -
delta(int) -
reason(CreditReason) -
note(str | None) -
grant_id(UUID | None) -
expires_at(datetime | None) -
created_at(datetime)
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:Truefrozen:True
Fields:
-
id(UUID) -
amount(NonNegativeInt) -
remaining(NonNegativeInt) -
origin(GrantOrigin) -
expires_at(datetime | None) -
request_id(UUID | None) -
created_at(datetime)
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(list[CreditEntry]) -
total(int)
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:Truefrozen:True
Fields:
WalletBalance
pydantic-model
¶
Bases: BaseModel
One of an organization's two credit balances.
Config:
from_attributes:Truefrozen:True
Fields: