Sandbox
@jhonsfran/unprice

Billing framework for AI usage and spend controls

Unprice sits in the request path so you can check entitlement, budget, wallet credits, and meter rules before an agent or workflow creates cost. It also keeps invoice evidence by tracing usage events and ledger captures back to charges.

36 stars5 forksTypeScriptUpdated 14d ago
Who it's for

Builders who need to control customer spend for AI products, agent runs, or metered workflows.

What it delivers

You can block unfunded work before it runs and still produce invoice evidence later.

What it does

Spend authorization

Checks entitlement, budget, wallet credits, and meter rules before work starts.

Budgeted runs

Sets budget envelopes for agents, workflows, jobs, tools, and other workloads.

Usage tracing

Links rated usage events and ledger captures to each charge.

Wallet and credit tracking

Separates purchased, granted, reserved, and consumed balances.

Stripe-backed payments

Uses Stripe as the production payment provider while Unprice manages the customer money path.

Agent skill install

Ships a skill playbook for Codex, Claude Code, Cursor, and other skills-compatible agents.

How to get it

  1. 1Install the Unprice SDK integration playbook in Codex, Claude Code, Cursor, and other…
    npx skills add https://github.com/jhonsfran/unprice --skill integrate-unprice-sdk
  2. 2The same skill is available through the documentation site
    npx skills add https://docs.unprice.dev --skill integrate-unprice-sdk

README

Unprice: open-source billing for AI credits and agent usage

GitHub stars Core license: AGPL-3.0-only Package license: MIT Commercial license

"Your product is smart, but your pricing is hardcoded."

Sell AI credits and usage without paying for unfunded agent work. Authorize each agent run or paid workflow before it creates cost, reserve customer credits up front, then trace settled usage to the invoice.

Billing is too late

For AI products, billing cannot start at the end of the cycle. By then, the model call, agent run, or paid workflow already created cost.

If the request should have been blocked, you already paid for it. When a customer disputes an invoice, engineering must reconstruct the path from product event to usage counter to billing line. Changing a package also means finding plan logic across application code, billing scripts, counters, and support workflows.

Put customer spend in the request path

Every AI charge starts with an authorization. Unprice gives your app that decision before the work runs.

  • Authorize before work runs. Check the plan, budget, wallet credits, and meter rules before an agent or workflow creates cost.
  • Keep invoice evidence. Trace each charge to rated usage events and ledger captures.
  • Inspect one money path. Usage, entitlements, budgets, credits, ingestion, and invoices share one evidence trail.

AI gateways cap what you spend with providers. Unprice governs what your customer is allowed to spend, then turns that decision into invoice evidence.

PriceOps is Unprice's operating model for versioned plan rules, entitlements, customer budgets, wallet credits, and invoice evidence.

Who it is for

Unprice is for developer-led AI products that sell prepaid credits, metered AI usage, agent runs, or paid workflows. It is built for CTOs, founding engineers, and platform engineers who own the path from customer authorization to invoice.

Licenses

This repository uses different licenses for the core and the client packages:

  • All project-owned files under packages/** use the MIT License.
  • All other project-owned files use AGPL-3.0-only. A separate commercial license is available for the core.

You can embed an MIT package such as @unprice/api in an application. Doing so does not apply the core AGPL license to that application. See LICENSING.md for the exact scope.

Why AGPL?

Money logic should be open to inspection.

  • Read the calculation. Inspect how the engine rates usage and moves money.
  • Share core changes. If you distribute a modified core, the AGPL requires you to publish those changes under the same license.
  • Keep control. Run the code in your account and keep your data there.

Use the commercial license if you need separate terms for the core.

Core capabilities

  • Customer spend authorization. Check entitlement, budget, wallet credits, and meter rules before paid work runs.
  • Budgeted runs. Set budget envelopes for agents, workflows, jobs, tools, and custom workloads, with run-level rejection before the work runs.
  • Runtime entitlements and metering. Check access and consume usage in the product request path.
  • Wallets and credits. Keep purchased, granted, reserved, and consumed balances separate from entitlement grants.
  • Invoice evidence. Trace every charge to rated usage events and ledger captures.
  • Bring your own payments. Stripe is the production provider today. Your provider captures the payment while Unprice keeps the customer money path.
  • Open and inspectable. Read the schemas for features, meters, entitlements, wallets, and runs, plus a generated SDK from OpenAPI contracts.

Tech stack

Unprice uses:

  • Next.js 15 with the App Router
  • Hono API and tRPC
  • Drizzle ORM and PostgreSQL
  • Cloudflare Workers
  • shadcn/ui and Tailwind CSS
  • Stripe payments today
  • Tinybird for analytics

Get started

Read the quickstart to put one agent action on the money path.

Agent skill

Install the Unprice SDK integration playbook in Codex, Claude Code, Cursor, and other skills-compatible agents:

npx skills add https://github.com/jhonsfran/unprice --skill integrate-unprice-sdk

The same skill is available through the documentation site:

npx skills add https://docs.unprice.dev --skill integrate-unprice-sdk

Unprice is open source. Bug reports, documentation fixes, and focused feature proposals are welcome.

Files in the repo

Repository payload39 top-level entries
  • .changeset
  • .cursor
  • .github
  • .husky
  • .vscode
  • apps
  • bin
  • docs
  • internal
  • packages
  • skills
  • tooling
  • turbo
  • .cursorignore
  • .cursorrules
  • .dockerignore
  • .gitignore
  • .infisical.json
  • .npmrc
  • .nvmrc
  • .prettierignore
  • .vercelignore
  • AGENTS.md
  • biome.json
  • CLAUDE.md
  • COMMERCIAL-LICENSING.md
  • CONTRIBUTING.md
  • docker-compose.yaml
  • knip.ts
  • LICENSE
  • LICENSING.md
  • package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml
  • PRODUCT.md
  • README.md
  • solo.yml
  • turbo.json
  • vitest.workspace.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k