> ## Documentation Index
> Fetch the complete documentation index at: https://docs.integrateledger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Per-unit API pricing

> Price several API products per 1,000 units, down to fractions of a cent, give free starting credit, then bill usage monthly.

> **Search:** $1 per 1,000 queries. **Parse:** $7.50 per 1,000 pages. **Extract:** $20 per 1,000 pages. $5 of free credit to start, then pay as you go, billed monthly.

Ledger prices every API product per unit, down to fractions of a cent, gives each signup free credit before a card, and bills usage monthly. Build it from one feature per product and a \$0 [pay-as-you-go](https://docs.integrateledger.com/pricing/pay-as-you-go.md) plan. Each request tracks its unit count as `quantity`. Choose the feature type by how you want the bill to read:

| | Credits features | Metered features |
| - | - | - |
| The customer's balance | One dollar balance across every product | One allowance per product |
| Free starting credit | A one-time grant at signup, before any card | A free allowance per product each month, on the plan |
| The invoice | One overage line for all products | One overage line per product |
| Use it when | Customers think in dollars of credit, and you want one number to show | Customers and your finance team want each product's units on the bill |

## With credits features

This uses the same scale as the [dollar balance](https://docs.integrateledger.com/pricing/dollar-balance.md): \*\*1 credit = $0.0001**, so $1 is 10,000 credits and a price per 1,000 units becomes a whole number of credits per unit. Each product's `creditCost` is its price per 1,000 units, in dollars, times 10:

| Product | Feature | Price | `creditCost` |
| - | - | - | - |
| Embed a chunk | `embed` | \$0.10 per 1,000 | 1 |
| Search | `search` | \$1 per 1,000 | 10 |
| Classify a page | `classify` | \$2.50 per 1,000 | 25 |
| Parse a page | `parse` | \$7.50 per 1,000 | 75 |
| Translate a page | `translate` | \$15 per 1,000 | 150 |
| Extract a page | `extract` | \$20 per 1,000 | 200 |

```ts ledger.config.ts theme={"system"}
import { defineCatalog, feature, plan } from "integrateledger-cli";

// 1 credit = $0.0001, so $1 = 10,000 credits.
export default defineCatalog({
	features: [
		feature({ id: "embed", name: "Embed a chunk", creditCost: 1 }), // $0.10 per 1,000
		feature({ id: "search", name: "Search", creditCost: 10 }), // $1 per 1,000
		feature({ id: "classify", name: "Classify a page", creditCost: 25 }), // $2.50 per 1,000
		feature({ id: "parse", name: "Parse a page", creditCost: 75 }), // $7.50 per 1,000
		feature({ id: "translate", name: "Translate a page", creditCost: 150 }), // $15 per 1,000
		feature({ id: "extract", name: "Extract a page", creditCost: 200 }), // $20 per 1,000
	],
	plans: [
		plan({
			id: "payg",
			name: "Pay as you go",
			monthlyCredits: 0,
			priceCents: 0,
			overageUnitAmountCents: 1, // 1 cent...
			overageBillingUnits: 100, // ...per 100 credits: $0.0001 a credit
			overageCapCents: 50_000, // $500 a month by default
		}),
	],
	creditPacks: [],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "embed", "name": "Embed a chunk", "creditCost": 1 },
    { "id": "search", "name": "Search", "creditCost": 10 },
    { "id": "classify", "name": "Classify a page", "creditCost": 25 },
    { "id": "parse", "name": "Parse a page", "creditCost": 75 },
    { "id": "translate", "name": "Translate a page", "creditCost": 150 },
    { "id": "extract", "name": "Extract a page", "creditCost": 200 }
  ],
  "plans": [
    { "id": "payg", "name": "Pay as you go", "monthlyCredits": 0, "priceCents": 0,
      "overageUnitAmountCents": 1, "overageBillingUnits": 100, "overageCapCents": 50000 }
  ],
  "addOns": []
}
```

**On signup, grant \$5 of credit:** a [balance adjustment](https://docs.integrateledger.com/customers/balance-adjustments.md) of 50,000 credits, as in [Free credits, then pay as you go](https://docs.integrateledger.com/pricing/recipes/free-credits-then-pay-as-you-go.md#the-calls). A customer with credits and no plan spends them on credits features, so the API works before a card is on file.

**On each request, check and track the units.** `quantity` is the page or query count; the use costs `quantity × creditCost`.

```typescript TypeScript theme={"system"}
const { allowed } = await billing.checkCredits({
	customerId: account.id,
	featureId: "extract",
	quantity: document.pageCount,
});
if (!allowed) {
	return res.status(402).json({ error: "add_a_card" });
}

const output = await extractDocument(document);

await billing.trackUsage({
	customerId: account.id,
	featureId: "extract",
	requestId: output.id,
	quantity: document.pageCount,
});
```

```python Python theme={"system"}
decision = billing.check_credits(
    customer_id=account.id, feature_id="extract", quantity=document.page_count
)
if not decision["allowed"]:
    return {"error": "add_a_card"}, 402

output = extract_document(document)

billing.track_usage(
    customer_id=account.id,
    feature_id="extract",
    request_id=output.id,
    quantity=document.page_count,
)
```

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/check \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "acct_17", "featureId": "extract", "quantity": 40}'

curl https://api.integrateledger.com/v1/track \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customerId": "acct_17", "featureId": "extract", "request_id": "ext_0091", "quantity": 40}'
```

A 40-page extract spends 8,000 credits, \$0.80:

```json Response theme={"system"}
{
  "allowed": true,
  "availableCredits": 42000,
  "chargedCredits": 8000,
  "overageCredits": 0,
  "overageRemainingCents": null,
  "request_id": "ext_0091",
  "idempotent": false
}
```

Show the balance as dollars: `availableCredits / 10_000`, here \$4.20.

**When the starting credit runs out, attach pay as you go.** `check` answers `reason: "no_plan"`; attach `payg`, and Checkout collects a card for a $0 subscription ([Checkout and attach](https://docs.integrateledger.com/billing/checkout-and-attach.md)). From then on every unit past the leftover credit is overage, and the renewal invoice has one line: "Pay as you go – overage, 420,000 credits", $42.00.

## With metered features

Each product has its own allowance and its own overage price. `overageUnitAmountCents` is whole cents, so a sub-cent price bills per batch with `overageBillingUnits`: parse at $7.50 per 1,000 is 3 cents per 4 pages, and extract at $20 per 1,000 is 2 cents a page. The free starting credit is a monthly allowance per product: 1,000 parsed and 250 extracted pages.

```ts ledger.config.ts theme={"system"}
import { defineCatalog, feature, plan } from "integrateledger-cli";

export default defineCatalog({
	features: [
		feature({ id: "parse", name: "Parse", type: "metered" }),
		feature({ id: "extract", name: "Extract", type: "metered" }),
	],
	plans: [
		plan({
			id: "payg",
			name: "Pay as you go",
			monthlyCredits: 0,
			priceCents: 0,
			items: [
				// $7.50 per 1,000: 3 cents per 4 pages.
				{ featureId: "parse", included: 1000, overageUnitAmountCents: 3, overageBillingUnits: 4 },
				// $20 per 1,000: 2 cents a page.
				{ featureId: "extract", included: 250, overageUnitAmountCents: 2 },
			],
		}),
	],
	creditPacks: [],
});
```

```json ledger.catalog.json theme={"system"}
{
  "schemaVersion": 1,
  "features": [
    { "id": "parse", "name": "Parse", "type": "metered" },
    { "id": "extract", "name": "Extract", "type": "metered" }
  ],
  "plans": [
    { "id": "payg", "name": "Pay as you go", "monthlyCredits": 0, "priceCents": 0,
      "items": [
        { "featureId": "parse", "included": 1000, "overageUnitAmountCents": 3, "overageBillingUnits": 4 },
        { "featureId": "extract", "included": 250, "overageUnitAmountCents": 2 }
      ] }
  ],
  "addOns": []
}
```

Attach `payg` at signup: the allowance comes with the plan, so the card comes first. The check and track calls are the same as above, with `quantity` as the page count. The track answers with the product's `balance`:

```json Response theme={"system"}
{
  "allowed": true,
  "availableCredits": 0,
  "chargedCredits": 0,
  "overageCredits": 0,
  "overageRemainingCents": null,
  "request_id": "ext_0091",
  "idempotent": false,
  "featureType": "metered",
  "chargedQuantity": 40,
  "balance": { "included": 250, "used": 290, "remaining": 0, "overageAllowed": true, "resetsAt": "2026-12-23T09:14:00.000Z" }
}
```

The renewal invoice has a line per product: "Pay as you go – Parse overage, 3,100" for $23.25, and "Pay as you go – Extract overage, 40" for $0.80.

## Rules

* **`quantity` is a whole number** of units, from 1 to 2,147,483,647 on one track.
* **One use is at most 2,147,483,647 credits** (\$214,748.36 at this scale), the same 32-bit limit as on the [dollar balance](https://docs.integrateledger.com/pricing/dollar-balance.md#rules): `quantity × creditCost` must fit, so one `extract` track covers up to 10,737,418 pages. A `creditCost` and the overage cap fit the same limit.
* **The scale sets the smallest price.** At $0.0001 a credit, the cheapest product is 1 credit a unit, $0.10 per 1,000. For cheaper products, pick a smaller credit before you publish.
* **Overage rounds once per period.** The period's overage credits are billed at 1 cent per 100, rounded up once: at most 1 cent over the exact total. Metered batches round the same way, per product.
* **Caps and overage.** [Overage](https://docs.integrateledger.com/pricing/overage.md) has the monthly cap, which cap applies on a metered-only plan, and how overage reaches the invoice.
* **Starting credit outlives the plan change.** A balance adjustment stands apart from plan grants, so the customer keeps it when `payg` is attached. Add `expiresAt` to make it lapse.
* **A feature keeps its type.** Choose credits or metered before you publish.

## Related

* [Free credits, then pay as you go](https://docs.integrateledger.com/pricing/recipes/free-credits-then-pay-as-you-go.md): the signup-credit flow in full.
* [Prepaid dollar balance](https://docs.integrateledger.com/pricing/dollar-balance.md): the same scale, priced at cost.
* [Pay as you go](https://docs.integrateledger.com/pricing/pay-as-you-go.md): the \$0 plan.
* [Metered allowances](https://docs.integrateledger.com/pricing/metered.md) and [Credits](https://docs.integrateledger.com/pricing/credits.md): the two feature types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.