Most diagrams are one page. A diagram with several pages is priced by its pages: a new three-page diagram is 15 credits, and a change that redraws two of its pages is 4. A request is charged once, when its result is kept; a retry with the same
Idempotency-Key is not charged again. Your plan’s credits are used first, then bought credits. Buy credits or turn on automatic top-up at https://app.diagramkit.ai/settings/api, where you also see your balance and this month’s use. When the balance cannot pay for a request, it is refused with 402 no_credits before any work starts, and nothing is charged.

A request is checked before anything is drawn, and charged once, when its result is kept.
error.type no_credits, a message saying how many pages were planned, the credits they need and the balance, and nothing drawn or charged. The API never asks before drawing, so a set of more than 30 pages needs your yes: send max_pages with the most pages you accept. Without it, a longer set fails with error.type too_many_pages and a message naming its page count and cost; send the request again with max_pages. A job’s time limit grows with its pages.