Bloga geri dön

Cheap OpenAI API Access Is a Billing Design Problem, Not a Price Hunt

Chasing the lowest per-token price rarely produces a cheap OpenAI API bill. What actually keeps spend under control is pre-hold settlement, automatic refunds on failure, exportable usage logs, and a balance that never expires.

Apiko Team

"What's the cheapest OpenAI API?" is the wrong question, and answering it usually leads to the wrong decision. Per-token price is one line in a bill you don't control unless three other things are true: you're only charged for what actually happened, failed requests don't cost you anything, and you can see exactly where the money went after the fact. Get those three right and the per-token rate stops mattering nearly as much as people expect. Get them wrong and a "cheap" rate card still produces a bill full of surprises.

This post is about the second thing — the billing mechanics that turn a metered API from a source of anxiety into a line item you can actually forecast.

Why the lowest sticker price doesn't guarantee the lowest bill

A per-token price is a rate, not a total. Your actual spend is a function of that rate multiplied by everything that happens around it — and most of the places where money leaks aren't visible in a pricing table at all:

  • Requests that fail after you've already been charged. If a provider bills on request initiation rather than on completion, a timeout, a rate limit, or an upstream outage can still cost you, even though you got nothing back.
  • Estimated vs. real usage. Some integrations charge a flat estimate per call instead of reconciling against the tokens a provider actually reports. Estimates are conservative by design, which means they're biased toward overcharging.
  • Balances that expire. Prepaid credit that evaporates at the end of a billing cycle is a cost even if you never see it itemized — it's spend you already made and didn't get to use.
  • No way to audit what happened. If you can't pull a line-by-line record of every call, every retry, and every charge, you're trusting the total on faith. That's fine until the total looks wrong and you have no way to check it.

None of these show up when you compare two numbers on a pricing page. They show up in the invoice, weeks later, as a total that doesn't match your mental model of what you used.

The three mechanics that actually control cost

A gateway that's serious about cost control needs to get three things right, and they compound: each one closes off a specific way a bill can drift from reality.

1. Pre-hold, then settle on real usage

The billing sequence that avoids both undercharging and overcharging looks like this: when a request starts, the gateway takes a pre-hold based on a conservative estimate of the tokens involved. When the upstream provider responds, the charge is settled against the real token usage the provider reports — prompt_tokens and completion_tokens, the same numbers you'd read back from the response yourself. You're never billed the estimate; you're billed what actually happened, down to the token.

This matters because it removes an entire category of "why is my bill higher than I expected" — the answer is never "the estimate was padded," because the estimate was never the final number.

2. Refund automatically when the upstream call fails

The second half of that sequence: if the upstream call fails — a 5xx from the provider, a dropped connection, anything that means you didn't get a usable response — the pre-hold is refunded automatically, and the request is not billed. You don't file a ticket, you don't wait for a manual review, and you don't have to notice the failure yourself for the refund to happen. This is the mechanic that makes retries and failover safe to build on top of: a gateway that automatically retries a failed request across channels can only be trustworthy if the failed attempts genuinely cost you nothing.

3. Usage logs you can actually audit

The first two mechanics only help if you can verify them. That means a usage log with enough detail to reconstruct any charge: model, prompt and completion tokens, latency, whether the call was streamed, and the exact amount billed, filterable by date range and exportable as CSV so you can reconcile it against your own request logs instead of trusting a dashboard total. A log you can export is also a log you can hand to a spreadsheet — sum by model, by day, by project, and see exactly where spend is concentrated instead of guessing from a single number at the top of a page.

Put together, these three mechanics turn "trust the total" into "verify the total" — and a bill you can verify is a bill you can actually plan around.

A balance that doesn't expire

The other half of cost control isn't about any single request — it's about what happens to money you've already committed. A balance that expires at the end of a billing cycle forces you to either overspend to avoid losing it, or underuse it and lose the unused portion anyway. Neither outcome is "cheap," even if the rate card looked competitive.

A balance that carries forward indefinitely removes that pressure entirely: credit added today is credit available whenever you use it, whether that's tomorrow or in six months, and it works across every model in the catalog rather than being scoped to one product surface. That single property — one balance, no expiry, usable across models — is what lets you buy in a lump sum without gaming your usage around a deadline.

Reading real usage back from the API

If you want to verify any of this yourself rather than taking it on faith, ask for usage data explicitly and read it from the response. With streaming enabled, request stream_options.include_usage so the final chunk carries the real token counts used for billing:

curl {GATEWAY_BASE_URL}/chat/completions \
  -H "Authorization: Bearer $APIKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Summarize this in two sentences: ..."}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'

Replace {GATEWAY_BASE_URL} with your deployment's gateway address, and swap model for whatever id you're actually calling — check the model catalog for the current list. Every OpenAI-compatible client library exposes the same usage object; the point isn't the specific request, it's the habit of reading prompt_tokens and completion_tokens back instead of assuming a number. If you're already routing through a gateway, pull a week of traffic from the exported usage CSV and compare the totals against what you expected — that comparison is the actual test of whether a "cheap" API is cheap in practice.

A cost-control checklist, not a price comparison

Before you evaluate an OpenAI-compatible API on price alone, check these instead:

  • Does billing settle on real token usage, or on a flat per-call estimate?
  • Are failed upstream calls refunded automatically, or do you have to notice and dispute them?
  • Can you export a usage log with per-request cost, filterable by date, to reconcile against your own records?
  • Does your balance expire, or does unused credit carry forward?
  • Does the price you see on a pricing page match what billing actually charges, or are they two different systems that can drift apart?

A rate card that scores well on all five of these will produce a predictable bill even if the headline per-token number isn't the absolute lowest you can find. A rate card that scores poorly on any of them can produce a surprising bill no matter how low the sticker price looked.

Try it with real requests, not estimates

The fastest way to check whether a gateway's billing mechanics hold up is to run real traffic through it and read the numbers back yourself. New accounts get trial credit automatically on signup — no card required — so you can send a batch of real requests, export the usage log, and confirm that pre-hold, settlement, and refund-on-failure behave the way this post describes before you commit any real budget. Sign up to try it, or go straight to the pricing page for live per-token rates across the full model catalog.