-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Background
As VM0 grows, we need a billing system to monetize the platform. Users run agents that consume compute resources (sandbox execution time), and we need to track this usage and charge accordingly.
Current State
The platform already has foundational elements in place:
- Run duration tracking:
startedAtandcompletedAttimestamps on agent runs, withexecution_time_msalready calculated in the API - User identity: Clerk-based authentication with scope system (personal/organization/system)
- Resource metrics: CPU, memory, and disk usage collected via Axiom (time-series data per run)
- Storage tracking: Size and file count per volume/artifact
What's Missing
- Usage aggregation (e.g., total run time per user per billing period)
- Billing/subscription data model
- Pricing configuration
- Payment processor integration
- Quota enforcement and usage limits
Requirements
Core Functionality
-
Usage Tracking
- Track total execution duration per user per billing period
- Aggregate run-level data into billable usage summaries
- Provide users visibility into their usage
-
Billing Model
- Support charging based on run duration (primary metric)
- Flexible enough to add other metrics later (run count, storage, resources)
- Handle billing periods (monthly)
-
User Scope
- Start with individual user billing
- Architecture should allow adding team/organization billing later
-
Usage Visibility
- Users can see their current usage
- Users can see their billing history
Acceptance Criteria
- Users can view their total run duration for the current billing period
- Usage data is aggregated and queryable per user per period
- System can calculate billable amounts based on usage
- Usage tracking does not impact run performance
User Scenarios
Scenario 1: User checks usage
A user wants to see how much compute time they've used this month. They can view a usage summary showing total run duration and estimated cost.
Scenario 2: End of billing period
At month end, the system calculates total usage for each user and generates billing records that can be used for invoicing.
Scenario 3: User approaches limit
If usage limits are implemented, users receive notification when approaching their quota.
Open Questions
- What billing model to use? (pure usage-based vs subscription + overage vs tiered plans)
- What granularity for duration tracking? (seconds vs minutes)
- How to handle failed/timeout runs in billing?
- Should there be a free tier? If so, what limits?
- What payment processor to integrate with?
Scope Boundaries
In scope:
- Usage tracking and aggregation
- Billing data model
- Usage visibility for users
Out of scope (for initial version):
- Team/organization billing (future enhancement)
- Complex resource-based pricing (CPU/memory weighting)
- Real-time usage alerts