Skip to main content
OpenType is prepaid. Your organization holds a credit balance, and every run draws its cost from it. This page is for whoever keeps that balance funded: it covers the four billing routes you call, the fields they return, how buying credit works end to end, and exactly what a run is charged. To manage billing by hand instead, use the Billing page in the console, which does the same without code.

How credit works

  • Every amount is an integer in micro-USD. 1,000,000 micros is 1 US dollar and 10,000 micros is 1 cent. balance_micros and a transaction’s amount_micros are signed; every other amount is unsigned.
  • Your balance is credited minus spent minus held. Purchases and grants add to it, usage takes from it, and every run in flight holds its spend ceiling, at most 20,000 micros ($0.02), until it settles.
  • A run needs 20,000 micros of available credit to start. It holds that whole ceiling while it runs, then settles at its real cost, which is usually far lower. If the balance after the hold would go below zero, the run is refused with 402 insufficient_credits.
  • New accounts start with $5 of credit (5,000,000 micros), granted once the email address is verified. There is one grant per email address. See Create an account.
For a sense of scale: a decision run that reads 412 input tokens and writes 23 output tokens costs 19 micros at Neon 1.1 prices, so $5 covers a little over 260,000 runs of that size. See Models and pricing for the price and the rounding rule.

Routes and who can call them

Which roles hold the two billing scopes: A key can only hold scopes its creator holds, so only an owner, admin or billing user can create a key with billing_write. A key that only sends runs needs neither billing scope. See Scopes and roles.

Read your balance

Each transaction has id, kind, amount_micros (signed: credit is positive, usage is negative), description and created_at. Transaction ids are txn_ plus 32 hex characters, except daily usage rows. Timestamps are UTC, in exactly YYYY-MM-DDTHH:MM:SSZ form. For spend older than the last 50 rows, read usage reporting instead.

Buy credit

POST /v1/billing/checkout takes the amount to buy and returns a Stripe-hosted checkout page. The credit is not added by this call: it arrives after the payment succeeds.
What happens next:
1

Pay on the checkout page

Open checkout_url in a browser. The line item reads OpenType credits. Paying also saves the card, which is what auto-recharge charges later.
2

Return to the console

Whether you pay or cancel, the checkout page sends you back to the console’s Billing page.
3

Wait for the credit

The credit lands once the payment succeeds, as a purchase transaction with the description Credit purchase. Poll GET /v1/billing until it appears.
A payment is credited exactly once, even if the payment confirmation arrives more than once.

Wait for a purchase to land

Record the newest transaction id before you open checkout, then poll until a new purchase row appears.

Cards, receipts and invoices

POST /v1/billing/portal takes no body and returns {"portal_url": string}, a Stripe billing portal where you add or change the saved card and download receipts and invoices. Leaving the portal returns you to the console’s Billing page. Add a card here if has_payment_method is false and you want auto-recharge without buying credit first.

What a run is charged

  • A completed run is charged its settled cost_micros: input and output tokens are each priced and rounded up to a whole micro separately, then summed.
  • A replay of an Idempotency-Key is never charged again. See Idempotency.
  • A refusal before any model call is free: every 400, 402, 409, 413 and 429, and every 503 or 504 raised before a model answered. The run’s hold is released.
  • A run that fails after the model answered is charged for what the model consumed, for example 503 provider_malformed_response.
  • The hold is not a charge. The 20,000 micros held while a run is in flight return to the balance when it settles; only the settled cost is spent.
Your daily usage transaction records those charges for one UTC day. GET /v1/usage/ledger lists every charged model call, one row each. See Usage reporting.

Errors

Billing errors use the envelope {"error":{"code","message","request_id"}}. The scope is checked before billing availability, so a key without the scope gets 403 even where billing is off. A malformed JSON body, a missing Content-Type, or an unknown field such as {"amount": 25} is refused before these checks with a plain-text 400, 415 or 422 that has no request_id in the body. Fall back to the HTTP status and the x-request-id response header. See Error handling.