Metering & Rate Card

Every metered surface flows through the gateway (the single chokepoint) and settles against the caller's prepaid wallet. This page is the shared vocabulary the surfaces were missing: for each one, who pays, at what rate, and by which mechanism. Rates are configurable via environment variables; the values below are the defaults.

Mechanisms#

Two settlement mechanisms, chosen by op size:

Rate card#

SurfaceOpPayerRate (default)MechanismEnv override
AIchat completioncallerOpenRouter's own per-token rates (prompt + completion) × 1.25 marginescrow (ai_call)— (upstream)
Databaseread / writeprivate → user; resource-owned → resource payer policy; creator-owned → actorper-op micro-USD (see pricing.ts)accumulate-and-flush (db_usage)
Storageupload (at-rest)private → uploader; resource bucket with payer:"owner" → resource owner; else uploader0.0001 micro-USD/byte, one-time at uploadescrow (storage_write)OSGARDEN_STORAGE_WRITE_MICRO_PER_BYTE
Storagedownload (egress)the fetching session0.00009 micro-USD/byteaccumulate-and-flush (storage_egress)OSGARDEN_STORAGE_EGRESS_MICRO_PER_BYTE

At-rest storage: the v1 model#

Object storage has an ongoing at-rest cost (bytes sitting on disk cost money every month), but osgarden currently charges it once, at upload time, as a per-byte storage_write capture. The write rate is padded so it amortizes the expected retention cost of a stored object.

The recurring GB-month sweep is deferred (post-v1). A correct recurring accrual needs machinery that does not exist yet: a periodic sweep sizing every owner's stored bytes, pro-rating partial months, crediting deletions, and re-pointing the payer when ownership transfers (retain/account-deletion). Until that lands, the padded one-time charge is the whole story. The storage_write and storage_egress ledger op types already exist, so adding the sweep later is additive — no schema change.

Invariants (from ROADMAP.md)#