# Hanzo Billing — Hanzo AI

> Recurring subscriptions, usage-based pricing, prorated upgrades, dunning, and tax.

Billing & Metering

Subscriptions, usage, invoices. Charge a fixed price, charge for what someone used, or charge for both on the same invoice. Plans, prices, meters, coupons and credits are separate objects, so a pricing change is a new price rather than a migration — and your servers never hold a card number to do any of it.

[Read the docs](https://docs.hanzo.ai/docs/cli/billing)[GitHub](https://github.com/hanzoai)

api\_requests120,000

price\_api\_metered$0.0020

Subscription$20.00

discount0%

Tax8%

Invoice

**cus\_abc123**

- Subscription_price\_api\_metered_$20.00
- api\_requests_× 120,000 · $0.0020_$240.00
- discount_0%_−$0.00
- Tax_calculated on the invoice · 8%_$20.80

Preview one before it is issued.$280.80

## The objects you bill with

What is Hanzo Billing

Small pieces that compose, rather than one plan type that has to cover every case.

billing.usage.record**7**

Meterapi\_requests

Period 1open

**Invoice**_cus\_abc123_Draft

- Subscriptionprice\_api\_metered
- api\_requestsmetering…
- Taxcalculated on the invoice

Preview one before it is issued.

1. ### Plans and prices
   
   01 / 03
   
   A plan says what someone gets. A price says what it costs. Keeping them apart is what lets you change a price without touching anyone already on the old one.
   
   Plan**api**
   
   - Price 14
   - Price 22
   
2. ### Meters
   
   02 / 03
   
   Post an event when something is used and the meter aggregates it. The invoice reads the meter at the end of the period, so nobody has to add up rows by hand.
   
3. ### Invoices
   
   03 / 03
   
   Line items assembled from the subscription and the meters, with tax calculated on the invoice itself. Preview one before it is issued, which is when a pricing mistake is still cheap.
   

## What the endpoint gives you

Capabilities

## Report the use, then charge for it

Get started

### Send your first meter event

Report what someone used, and let the invoice read the meter at the end of the period.

[Read the docs](https://docs.hanzo.ai/docs/cli/billing)[View on GitHub](https://github.com/hanzoai)

[Billing — Hanzo](https://hanzo.app/home)

- gatewayReady
- payments-apiReady
- checkout-webBuilding
- docs-siteReady

The service the session above is changing.

api.hanzo.ai**/v1/billing**[Open in the console ↗](https://hanzo.team/)

Example project. Every name in it is one you would give your own.

typescript

```
import { Hanzo } from '@hanzo/billing';

const billing = new Hanzo({ apiKey: process.env.HANZO_API_KEY });

// Report usage in real time
await billing.usage.record({
  customer: 'cus_abc123',
  meter: 'api_requests',
  value: 1,
  timestamp: new Date(),
});

// Subscribe with metered pricing
await billing.subscriptions.create({
  customer: 'cus_abc123',
  items: [{ price: 'price_api_metered' }],
  payment_behavior: 'default_incomplete',
});
```

Paste and ship

Paste this into any agent. It reads the skill manifest and calls Billing from there.

Agent promptapi /v1/billing

```
Read https://hanzo.ai/skill.md and use Hanzo Billing in my project. Start with: hanzo billing balance
```

## Get Billing

Metered billing engine

License: Apache-2.0[hanzoai](https://github.com/hanzoai)[Deploy to Cloud](https://platform.hanzo.ai/deploy)
