dataflow.auth.credits¶
Attributes¶
Classes¶
Manager for user credits and usage tracking. |
|
Record of agent usage. |
Module Contents¶
- class dataflow.auth.credits.CreditsManager¶
Manager for user credits and usage tracking.
- async check_credits(user_id: str, required_credits: float = 1.0) bool¶
Check if user has sufficient credits.
- Parameters:
user_id – User ID
required_credits – Required credits for the operation
- Returns:
True if user has sufficient credits, False otherwise
- async deduct_credits(user_id: str, amount: float) bool¶
Deduct credits from user account.
- Parameters:
user_id – User ID
amount – Amount to deduct
- Returns:
True if deduction was successful, False otherwise
- async log_usage(usage: UsageRecord) bool¶
Log agent usage for billing and analytics.
- Parameters:
usage – Usage record
- Returns:
True if logging was successful, False otherwise
- property client¶
Lazy-loaded Supabase admin client.
- config¶
- class dataflow.auth.credits.UsageRecord(/, **data: Any)¶
Bases:
pydantic.BaseModelRecord of agent usage.
- cost: decimal.Decimal¶
- created_at: datetime.datetime | None = None¶
- dataflow.auth.credits.logger¶