Skip to content
Docs

Credits

How usage is counted

Meters charge after authentication and before the request is processed. Usage is recorded daily per project.

Overview

Before a metered Cloud handler runs, Gray3 checks the remaining allowance, then atomically increments a daily usage row for that organization, project, day, and meter. Failed auth does not consume credits; an exhausted allowance fails before any chain data is requested.

Flow

  1. Authenticate project credentials
  2. Resolve plan + owner credit period
  3. Look up the cost for the meter, using the default table or your plan's custom rate
  4. If used + cost > allowance, return credits_exhausted (402)
  5. Otherwise increment usage and proceed
javascript
// Conceptual — not a public client API
const charged = cost(meter); // e.g. portfolio_get → 1
if (used + charged > allowance) throw credits_exhausted;
// upsert usageDaily { organizationId, projectId, day, meter } += charged

Attribution

  • Project — which proj_… made the call
  • Organization — billing parent that owns the allowance
  • Day — UTC day buckets for charts
  • Meter — which operation class was charged

Credit period

Usage sums across the owner's current credit period (from creditPeriodStart to creditPeriodEnd). The remaining balance is the allowance minus the credits used in the period and minus this charge.

Console mapping: How usage maps to Cloud calls.