Skip to content

Build a metered AI SaaS without confusing credits and dollars

Separate provider spend, reservations, usage and customer allowances before launching a paid AI feature.

Measure two things separately

An AI feature has a provider bill and a product budget. Dollars answer what the model provider charges your account. Credits answer how much work your application authorizes for a customer. A pricing plan can bundle credits, but those units do not become prepaid provider funds.

FoundryLayer includes the source for workspace subscriptions and integer credit accounting. The $149 Founding 50 offer buys the source license, not a hosted subscription or model balance.

Begin with a representative workload

Count primary calls, delegated agents, calls per delegate, and input/output tokens per call. Include repeated context and tool results. Multiply by actual active users and run frequency rather than assuming every signup has the same workload.

Use the AI Agent Cost Calculator to inspect the arithmetic with your own provider prices. Its default prices are illustrative; verify your account’s applicable rates independently. Caching, reasoning tokens, retries and non-model services need separate assumptions.

Reserve before the model call

An average estimate cannot protect a live run that expands its context. FoundryLayer reserves a conservative budget before provider execution and constrains the agent graph’s model calls, tools and steps.

The current token policy rounds input plus output tokens up to one unit per 1,000 tokens per call. Four small calls may cost more integer units than a single call containing the same combined token count. Model prices and unit policy are independent.

Code

One call: 1,100 total tokens -> 2 units
Two calls: 550 tokens each -> 1 + 1 = 2 units
Three calls: 367 tokens each -> 1 + 1 + 1 = 3 units

These are arithmetic examples, not measured benchmark results.

Settle without rewriting history

After a call, reliable observed usage supports transactional reservation reversal and actual debit. Unknown usage or a settlement failure can retain the reservation. Known unbilled results have a separate zero-settlement path.

Immutable ledger operations, lots, idempotency keys and workspace locks protect grants and concurrent spending. Usage measurements remain separate records. Read credits and model costs before changing a customer allowance or token policy.

Keep payment state authoritative

The reference app’s supported Stripe subscriptions are flat-rate monthly or annual workspace plans. Paid access comes from signed webhook reconciliation against current subscription and invoice state. Browser returns are navigation, not entitlement grants.

Live workspace checkout and the source checkout remain closed until their respective readiness gates pass. A commercial website redesign is not authority to open either one.

Build the first slice

Follow the quickstart to create a verified user and personal workspace, grant a reasoned development budget, run a real General task and inspect the persisted answer and charge after reload. Then adapt the first-project walkthrough.

Evaluate hosting, database, transactional email, research and integration costs alongside model spend. A passing local flow is a starting point for independent deployment acceptance, not a production certification.

Inspect the mechanism.

Build on a foundation you own.

$149 USD once. One developer seat. Unlimited owned and client projects. Prelaunch.

Explore the license