Skip to content

Add monthly model credits and auditable usage billing - #1878

Merged
elie222 merged 4 commits into
mainfrom
codex/monthly-model-credits
Oct 22, 2026
Merged

elie222 merged 4 commits into
mainfrom
codex/monthly-model-credits

Conversation

@elie222

@elie222 elie222 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Why

Offer free use with a personal API key or prepaid hosted model usage, with charges that can be reconstructed from durable financial records.

What changed

  • Add monthly model credits from $10 through $500 and one-time top-ups. Upgrades charge the prorated difference immediately; downgrades begin at renewal. Monthly grants expire, purchased top-ups remain, and expiring funds are spent first.
  • Add a Postgres append-only audit journal, per-call usage and provider receipts, atomic settlement, source allocations, and bounded reconciliation. Wallet and grant tables are projections; financial history survives lifecycle deletion. Migrations remain additive and preserve previous-writer compatibility.
  • Add normal application user IDs and Rakazo app attribution to OpenRouter inference. Keep provider translation inside adapters.
  • Keep billing opt-in: with Stripe billing disabled, no new paywall, purchases, or credit debits are enabled. Usage and audit improvements still apply.
  • Align credit capability checks, preserve managed models alongside personal connections, and exclude tax/unrelated invoice items from model credits. Refunds reduce the eligible paid portion proportionally.
  • Release holds for proven pre-generation rejections while retaining uncertain calls, recover saved receipts over incomplete usage rows, and let BYOK accounts resume existing credits without another purchase. Credit mode selects hosted credentials for the managed provider while preserving saved personal keys.

UI copy

The funding choice uses “Choose how to use Rakazo”, “Your API key”, “Pay your model provider directly.”, “Use my API key”, “Rakazo credits”, “$10 / month”, “$10 in monthly model credits. No API key needed.”, “Continue with credits”, “Bots and browser automation”, “Scheduled routines”, “Web, desktop and mobile”, “Models at provider cost”, and “Top up anytime”. Amounts follow the selected tier. These visible labels distinguish funding methods and show that both paths include the same product features; hiding them would obscure the purchase decision.

Billing-only copy is “Available credits”, “Refresh credits”, “Monthly credits”, “Upgrade now”, “Downgrade at renewal”, “Monthly credits expire at renewal. Top-ups do not expire.”, “Add credits”, “Credit amount”, “One-time purchase. Credits do not expire.”, “Continue to checkout”, and “Using your API key”. “Use Rakazo credits” is shown when switching from personal setup; “Could not update billing” appears only after a failed action. These details are revealed only in billing settings, purchase dialogs, or the relevant error state.

Validation

Focused billing, catalog, API, and Postgres accounting tests pass, including disabled-billing endpoints, replay/refund handling, proration, tax/mixed invoices, renewal expiry, and previous-writer holds. Project-wide typechecking and lint pass with existing warnings. The signup/monthly-checkout/top-up browser flow and resuming existing credits passed locally. Crash recovery, provider rejection, interrupted-stream receipts, credential selection, and disabled billing have regression coverage. Hosted authentication without an API key is also covered. Stripe sandbox checkout, upgrade, downgrade, top-up, and provider metering were exercised locally.

CI passed the validation workflow, including unit tests, Postgres journeys, native checks, production builds, and all web E2E shards. Native billing uses shared contracts and native menus; its types and translations were checked. CI captures the shared web/Electron UI; native mobile screens cannot be captured by this suite and were not exercised on a device.

CI screenshots: billing credit choice, billing credit options, billing use existing credits.

Production deployment and the compatible mobile update completed successfully in the main CI run.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
rakazo-www Skipped Skipped Oct 22, 2026 12:08pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The latest changes appear safe to merge, with the hosted judge credit-check issue fixed.

Summary

Adds monthly model credits, permanent top-ups, and durable records for model charges.

  • Owners can choose personal model keys or buy Rakazo credits for hosted models.
  • Hosted model calls reserve credits and record provider usage.
  • Credit balances keep an audit trail through purchases, model calls, and expiry.
  • Members can keep personal providers while choosing managed models.

Diagram

sequenceDiagram
  participant Judge
  participant Credits
  participant Provider
  participant Database
  Judge->>Credits: Create observer for hosted funding
  Credits->>Database: Reserve credits before the call
  Judge->>Provider: Call using deployment credentials
  Provider-->>Judge: Return usage
  Judge->>Database: Save receipt
  Judge->>Database: Record usage and settle credits together
Loading

Reviews (3) · Last reviewed commit: "fix: meter hosted judge calls with keyle..." · Reviewed by Greptile

Comment thread packages/adapters/src/pi-usage.ts
Comment thread packages/adapters/src/model-credit-reconciler.ts Outdated
Comment thread apps/web/src/components/ModelCredits.tsx
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Playwright screenshots

Feature frames for this PR:

Open screenshot gallery · Dashboard · CI run

Updated for commit 494200b.

Comment thread apps/api/src/team-chat-judge.ts
@elie222
elie222 merged commit 136088d into main Oct 22, 2026
25 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 494200b4 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant