How to lower your OpenAI API costs
Ways to reduce OpenAI API costs: cut tokens, cache prompts, batch offline work, and test a smaller model on your own data before you switch over.
Updated
To lower your OpenAI API costs, find the few calls that make up most of the bill, cut the tokens each one sends and returns, move work that can wait onto batch pricing, and send narrow tasks to the smallest model that passes your own tests. Most of the savings come from a handful of code paths. Shaving words off every prompt helps less than people expect.
Find the calls that drive the bill
The usage dashboard shows spend by model and by day, but not by feature. Tag every request with the feature or code path that made it, then add up cost for each tag. In most products one or two paths account for most of the spend. The usual culprits are a summary that regenerates on every page view, a nightly job that reprocesses files it already handled, and a retry loop that resends the full prompt after each timeout. To put a figure on each call, the LLM cost calculator turns your token counts into a monthly estimate.
Here is how to read the result. Suppose a support dashboard rebuilds a long ticket history on every reload, and reloads happen far more often than anyone planned. Removing that one call, or caching its output, can save more than trimming the system prompt in every other feature combined. Sort the tags by cost and work down the list. Do not start with the prompt text.
Cut tokens without cutting quality
Four changes usually come first:
- Shorten the system prompt. Repeated instructions are billed on every call, so a long preamble costs you again and again. Delete rules the model already follows, and keep the ones your tests show it breaks.
- Put static content first. Prompt caching only helps on a repeated prefix, so instructions, output schemas and reference text belong before the part that changes per request. The prompt caching savings guide explains how the discount applies.
- Cap the output. Ask for fields or a short answer instead of prose, and set a maximum output length on the request. Output tokens are priced higher than input tokens on most models, so this often saves more than shortening the input.
- Send only the section a task needs. A clause-finding task needs the clauses, not the full document with its appendices and signature pages.
Reasoning models bill their hidden reasoning as output. For classification or field extraction, test a model without extended reasoning first. Many of these tasks pass without it, and the bill drops with no change to the product. The reasoning tokens guide covers how to measure that cost.
Check quality after every cut. The common mistake is trimming until the model loses a rule that only matters on edge cases, such as a date written in an unusual format. Count the tokens, then rerun the test set.
Batch the work that can wait
Not every call needs an answer in seconds. Tagging a backlog, backfilling a database or scoring a stored set of documents can run asynchronously and finish overnight. OpenAI offers a batch interface at a discount, so check the current pricing page for the rate before you plan around it, since prices change.
Ask one question for each feature: how long can a user wait for this result? If nobody reads the output in real time, batch it. Anything that shows a result on screen while someone waits usually has to stay real-time. For a fuller comparison of when the discount is worth the delay, read batch APIs vs real-time calls.
Send narrow tasks to a smaller model
Frontier models are built for open-ended work. A narrow job, such as pulling effective dates out of contracts or sorting support tickets into queues, often does not need one. Whether a smaller model is good enough depends on your data, so test it instead of guessing.
Test before you switch:
- Collect real examples from your product, not a generic sample.
- Split them by document or account, so the same source never appears in both your examples and your test set.
- Score the current model on the test set, then score the cheaper model on the same set.
- Keep the cheaper model only if it holds up on the messy cases, such as scanned text, very long inputs and ambiguous wording.
- Move one task at a time, and keep the current model as the fallback for everything else.
The LLM evaluation guide covers how to build that test set without a research team.
Mistakes to avoid and a checklist
Four mistakes come up again and again:
- Editing the prompt before finding the expensive call.
- Comparing per-token prices across vendors without counting tokens per task. A cheaper model that writes twice as much output can cost more.
- Switching the whole product after one good test.
- Ignoring retries. A timeout that resends a long prompt is billed again every time.
A short checklist for the next review:
- Tag each request by feature and list the top three by cost.
- Move repeated instructions out of the system prompt and put stable text first.
- Set a maximum output length on every call that does not need prose.
- Cap retries, and log the token count of each attempt.
- Move offline work to batch.
- Score a smaller model on your own examples before any switch.
A free AI cost audit maps your spend by task, from your code and invoices, and shows which calls are worth moving first. Own Weights offers it, and you can book a call to talk through the results before you decide anything.
Questions
Why is my OpenAI API bill so high?
Most bills are driven by a few calls that run far more often than anyone planned, such as a summary on every page view or a retry loop that fires after each timeout. Group your usage by feature to find them. Then check whether those calls resend large prompts or ask for long output.
Does prompt caching lower OpenAI API costs?
It can, when the start of your prompt is the same across many calls. Repeated prefixes are billed at a discount on supported models, and the terms depend on the model and the minimum prompt size. Check OpenAI's current prompt caching documentation for the exact rules.
Should I move from OpenAI to a cheaper model to save money?
Only after you test it. Run both models on real examples from your own product and compare the scores on the cases that matter most. If the cheaper model holds up, move that one task first and leave the rest where it is.