PayAPIKey
Back to guides
Billing9 min read

What Is API Key Billing?

A practical guide to API key billing models, usage tracking, pricing units, invoices, limits, and developer-friendly policies.

API key billing connects identity, usage, and pricing

API key billing is the process of connecting a developer's access key to measurable usage and then turning that usage into a bill, limit, or plan entitlement. A key identifies who is making requests. Usage records explain what happened. Pricing rules decide what that activity costs.

For a simple API, billing may be requests per month. For an AI API, billing usually includes token volume, model type, retries, context length, and sometimes fixed request costs. The important shift is that the API key becomes the unit of accountability. Every request should be attributable to a customer, workspace, plan, or internal project.

The core billing objects

Most API billing systems share a small set of concepts. You do not need a large billing platform to understand them, but you do need consistent naming and measurement.

ObjectPurposeExample
API keyIdentifies the callersk_live_... mapped to workspace A
MeterCounts usageRequests, input tokens, output tokens
PriceTurns usage into cost$2.50 per 1M input tokens
LimitPrevents runaway usage100k requests per month
Invoice lineExplains the charge42M output tokens x rate

Common pricing models

Usage-based billing charges customers for what they consume. Subscription billing charges a recurring fee for a bundle of access. Hybrid billing combines both: a base plan includes a quota, and overages are billed after the quota is consumed.

For developer products, hybrid billing is often easier to sell because customers can predict a minimum bill while still growing without a hard stop. Free tiers can work well when the abuse controls are strong and the unit economics are known.

  • Request-based pricing: simple, readable, and useful for traditional APIs.
  • Token-based pricing: better for AI APIs where request size varies widely.
  • Credit-based pricing: abstracts multiple model prices behind one wallet unit.
  • Plan-based quotas: easier for buyers, but risky if usage patterns vary.

A small billing example

Imagine an AI API customer makes 300,000 requests per month. Each request averages 1,200 input tokens and 800 output tokens. If input tokens cost $2.50 per million and output tokens cost $10.00 per million, the provider cost is easy to estimate before adding support, servers, payment fees, and margin.

Monthly cost = (300,000 x 1,200 / 1,000,000 x $2.50) + (300,000 x 800 / 1,000,000 x $10.00) = $3,300

What a useful API billing setup should show

A customer should be able to see the API keys they created, current usage, remaining quota, rate limits, expected bill, and policy restrictions. A team owner should be able to rotate keys, revoke keys, set project-level limits, and understand why a bill changed.

The public pricing page should match the billing math inside the product. If your page says requests are billed per 1,000 but invoices show token-level charges, developers will lose trust. The safest path is to publish formulas, examples, and definitions next to the calculator.