Pool API Architecture

Credit Pool API

Architecture patterns for shared credits, usage allowances, quotas, reward points, and reservation-based accounting—without double-spend or mystery balances.

What this pool coordinates

One policy boundary for shared capacity

Credit pools coordinate a finite allowance across people, projects, API keys, agents, or services. They can represent model tokens, compute time, prepaid API usage, internal points, or promotional grants. The core system is an append-only ledger plus policy: accounts hold distinct units, reservations make concurrent use safe, quotas protect infrastructure, and reconciliation turns measured work into final entries.

Build the contract before the marketplace

+

Separate balances, quotas, and points

A balance records value or entitlement. A quota limits activity during a window. A point may record participation or rewards. They can appear in one dashboard, but they need separate data models and rules. Clear boundaries keep a rate limit from looking like money and keep a promotional point from being treated as a refundable credit.

+

Reserve before uncertain work

When the final cost is unknown, atomically reserve a conservative amount, run the work, commit measured usage, and release the remainder. Every mutation uses an idempotency key. Lease expiry and reconciliation policies handle timeouts, retries, and delayed provider callbacks.

+

Keep an immutable ledger

Record grants, purchases, reservations, commits, releases, expirations, refunds, and adjustments as immutable entries. Materialize balances for speed, but preserve the event history that explains every unit. Corrections become compensating entries instead of silent edits.

+

Design for account hierarchies

Organizations often need parent budgets, project subaccounts, provider-specific buckets, expiring grants, and environment limits. Make inheritance and fallback explicit. Deterministic spend order and per-entry funding detail keep reports and disputes understandable.

The control-plane pieces

Use these modules as separate services or bounded components. Their contracts matter more than how many repositories contain them.

Reference module

Ledger

Append-only entries, fixed precision, compensating corrections.

Reference module

Reservations

Atomic reserve, commit, release, renew, and expire paths.

Reference module

Quotas

Requests, units, concurrency, and period-based limits.

Reference module

Reconciliation

Compare observed usage with committed ledger entries.

Reference module

Reporting

Project, provider, key, model, and cost-center views.

Reference module

Roles

Separate consumer, operator, finance, support, and auditor access.

A concrete API shape

This example is an architecture pattern, not a live PoolAPI.com endpoint. It shows explicit identifiers, units, limits, and idempotency rather than hidden defaults.

POST /credit-reservations
{
  "account_id": "acct_project_alpha",
  "unit": "model_credit_milli",
  "maximum": 25000,
  "expires_in_seconds": 120,
  "idempotency_key": "req_01J..."
}

Common design decisions

Is a credit pool the same as a rate limiter?

No. A rate limiter controls activity over time, while a credit pool accounts for a finite allowance or value. A system can enforce both on the same request.

Should credits use floating-point numbers?

No. Use integers in the smallest unit or fixed-precision decimals with a declared scale.

Can credits expire?

Yes, but expiration should be a ledger event governed by a visible policy, not an unexplained balance overwrite.

How are duplicate charges prevented?

Require idempotency keys and make balance checks plus reservation creation atomic.

Go deeper

All guides
Credit Pool API Design featured graphic
API Operations · June 27, 2024

Credit Pool API Design

How to model pooled API credits without double-spend, ambiguous balances, or retry bugs—and how to separate limits from accounting.

credit poolsusage ledgers
What Is a Pool API? featured graphic
Pool API Fundamentals · February 14, 2024

What Is a Pool API?

A field guide to the resource model, lifecycle, control plane, allocation rules, and reliability patterns behind APIs that coordinate shared pools.

pool apiresource allocation
Model Pool API Architecture featured graphic
AI & Agents · November 8, 2024

Model Pool API Architecture

A practical blueprint for routing across LLMs without hiding capability differences, cost controls, reliability signals, or evaluation evidence.

llm routingmodel pools