qfa.api.schemas_usage#

HTTP-layer wrappers over the domain usage stats.

ADR-007 keeps API and domain models separate where the API needs to hide internal fields or reshape the wire format. The usage endpoints don’t need either — the domain UsageStats is the aggregate the consumer wants. The only HTTP-specific addition is the echoed from/to query window, so this module holds two thin wrappers that add those fields and nothing else.

Classes

AllUsageStatsResponse(*[, from_, to])

Per-tenant + grand total usage with optional echoed time window.

UsageStatsResponse(*[, tenant_id, ...])

Domain UsageStats plus echoed from/to query bounds.

class qfa.api.schemas_usage.UsageStatsResponse(*, tenant_id: str | None = None, total_calls: int, failed_calls: int = 0, total_cost_usd: Decimal = Decimal('0'), call_duration: DistributionStats, input_tokens: TokenStats, output_tokens: TokenStats, from_: datetime | None = None, to: datetime | None = None)[source]#

Bases: UsageStats

Domain UsageStats plus echoed from/to query bounds.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config = {'frozen': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

from_: datetime | None#
to: datetime | None#
class qfa.api.schemas_usage.AllUsageStatsResponse(*, from_: datetime | None = None, to: datetime | None = None, tenants: list[UsageStats], total: UsageStats)[source]#

Bases: BaseModel

Per-tenant + grand total usage with optional echoed time window.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

from_: datetime | None#
to: datetime | None#
tenants: list[UsageStats]#
total: UsageStats#