How to reduce LLM API costs
To reduce LLM API costs, change one of the four terms of the bill: which model you call, how many tokens you send, how many it writes back, and the rate each token is billed at. Measure cost per request first, then pull the levers that move your largest term: model choice, output length, caching, batch and routing.
A HIPS guide. Updated . Every price names its source and the day it was read.
The bill, term by term
Every per-token API bills each request the same way:
cost = input tokens × input rate + cached input tokens × cached rate + output tokens × output rate
Each lever below shrinks one term. Know which term is largest in your traffic before you choose.
| Lever | Term it moves |
|---|---|
| A smaller model | Every rate |
| Shorter answers | Output tokens |
| Shorter prompts | Input tokens |
| Prompt caching | Moves input tokens to the cached rate |
| Batch | Every rate, for work that can wait |
| Off-peak pricing, where offered | Every rate, by the hour |
| Routing by difficulty | Every rate, request by request |
| Caching whole answers in your app | Removes the request |
| Capping retries and agent steps | Removes requests |
| Self-hosting | Replaces the rates with an hourly GPU cost |
Lever 1: measure every request
You cannot cut what you cannot see. Record, for every request, the model, the input, cached and output token counts and the cost, tagged with the feature, customer or agent that sent it. A week of that shows which term and which feature drives the bill. Most APIs return token counts in each answer; multiply them by the model's published rates if the API does not return the cost itself.
LLM cost optimization, lever by lever
2. Call the smallest model that passes your test
Prices differ more between models than any other lever moves them. On HIPS's catalog of December 1, 2026, a million output tokens in the Certified pool cost:
| Model | Input, per million | Output, per million |
|---|---|---|
| gpt-oss-20b | $0.0176 | $0.0882 |
| gpt-oss-120b | $0.0294 | $0.147 |
| Qwen3.6 35B A3B | $0.049 | $0.686 |
| DeepSeek V4.1 Flash | $0.098 | $0.70 |
| GLM 5.3 | $1.05 | $3.36 |
| Kimi K3.1 Pro | $2.10 | $14.00 |
Build a test set from your own requests, with the answers you would accept, and run it against several models. Use the smallest one that passes. Re-run the test when a new model appears.
3. Ask for shorter answers
Output is usually the dearer token. On the same catalog, gpt-oss-120b's output rate was five times its input rate. Set a maximum output length on every request, ask for the format you need (a JSON schema in place of prose), and tell the model to be brief. A cap only cuts an answer off; a clear instruction makes it shorter.
4. Send less input
Every token you send is billed. Trim the system prompt, send only the retrieved passages a question needs instead of whole documents, and summarize long conversations instead of resending every turn.
5. Put the unchanging part first, for prompt caching
When requests start with the same text, many APIs bill that repeated beginning at a lower cached rate. The rules differ by provider. OpenAI's documentation, for example, says you "Pay the model’s reduced cached-input rate for reused tokens, discounted up to 95%," and that "For GPT-5.6 and later, cache writes cost 1.25× the standard, uncached input-token rate for the default 30-minute lifetime."[1] Two habits help everywhere: keep the system prompt, tools and shared documents at the start and in the same order, and put what changes, such as the user's question, last. Check whether writing to the cache costs extra, and how long a cache lives.
6. Batch what can wait
Work that does not need an answer now, such as evaluations, document runs or nightly reports, can go through a batch API. OpenAI's Batch API offers a "50% cost discount compared to synchronous APIs" and says "Each batch completes within 24 hours (and often more quickly)".[2] HIPS's batch rules are in the HIPS section below.
7. Use off-peak hours, where a provider prices them
Some providers price by the hour of the day. DeepSeek's pricing page says "Off-peak rates are half of the peak rates." and "Peak hours are 01:00 - 04:00 and 06:00 - 10:00 UTC, Monday through Friday, excluding Chinese public holidays."[3] Schedule work that can move.
8. Route each request by difficulty
Most traffic does not need your largest model. Send simple requests to a small model and the hard ones to a large one, by rules (request type, length) or by a classifier. Check the result with the same test set as lever 2.
9. Answer repeated questions from your own cache
If users ask the same question in the same words, store the answer and serve it again without calling the model. Set an expiry, and never share a cached answer between users who should not see each other's data.
10. Cap retries and agent loops
An agent that loops, or a client that retries without a limit, multiplies the bill. Set a maximum number of steps per agent task, a timeout per request and a limit on retries, and alert when a task passes them.
And when volume is steady: self-host
A GPU billed by the hour can cost less per token than an API once it is busy enough. The self-hosted LLM guide gives the break-even formula with a worked example.
LLM cost management: budgets and attribution
Optimization lowers the price of each request; cost management keeps the total where you planned it.
- Attribute every request. Tag it with the feature, customer and environment, so a rise in spend points at its cause.
- Set budgets with an action. Decide in advance what happens at the limit: an alert, or a stop.
- Alert before the limit. Warn at a fraction of the budget, not at the end.
- Give each key its own limit. A leaked or runaway key then costs at most its own budget.
- Review monthly. Compare cost per request and cost per feature with last month, and re-run the model test when prices change.
Reducing costs on HIPS
HIPS serves open models through one OpenAI-compatible API, priced per token, per model. What it gives you for each lever:
- Every answer carries its cost.
usageholds the token counts; the charge is in thex-hips-cost-microsheader, never inusage. Every rate is public, with its history. - Batch at half the rate. For work that does not need an answer right away, batch jobs let you send many requests at once in one file, in the OpenAI-style batch format. HIPS runs them as capacity becomes free, within a window you choose from 24 hours to 7 days, and tells you when they are done. A batch costs half the on-demand rate of the same model. No completion time is promised: requests still unfinished when the window closes come back as expired and are not charged.
- Prompt caching with no write charge. Prompt caching is automatic, and writing to a cache costs nothing. No hit is promised. Input tokens your usage reports as cached are billed at the model's cached-input rate.
- Open models at their own rates. Change the base URL and the key, and the same client code calls every model in the catalog; the table in lever 2 shows the spread.
- Routing, in preview. Semantic routing lets you send a router's name in place of a model, and HIPS chooses a model for each request by the preference you set: the shortest measured time, the lowest expected charge, or the most capable model. Each request is billed as the model chosen. See Semantic routing in the Docs.
- Budgets. A monthly spend budget for the workspace, with its action when reached. Budget guardrails can also give a member, an API key or a tool its own budget.
HIPS never trains on, retains or logs your prompt data.
Questions about LLM API costs
How do I reduce LLM API costs?
Measure the cost of every request, find the largest term of your bill, and move it: a smaller model, shorter answers, less input, prompt caching, batch for work that can wait, and routing by difficulty. Set budgets so the total stays where you planned it.
What is LLM cost optimization?
Lowering the price of each request without losing the quality you need: choosing the model, shaping prompts and answers, and using the lower-priced billing modes a provider offers, such as cached input and batch.
What is LLM cost management?
Keeping total spend under control: attributing each request to a feature or customer, setting budgets with alerts and stops, giving each key its own limit, and reviewing the bill every month.
Why do output tokens cost more than input tokens?
A model reads the whole prompt in one parallel pass, but writes its answer one token at a time, and each step must read the model's weights from memory again. NVIDIA calls that generation step "a memory-bound operation".[4] Many providers price output above input for that reason; see LLM inference, explained.
Does prompt caching always reduce cost?
Only when requests share the same beginning, and only if the cached tokens are actually reused. Some providers charge extra to write a cache, so a prefix used once can cost more than no cache at all. Check each provider's rules.
Is a batch API worth it?
For work that can wait hours, usually: the rates are lower and nothing changes in the request itself. It does not suit anything a user is waiting for.
Sources
- [1]
OpenAI, prompt caching documentation, read December 2, 2026.
developers.openai.com/api/docs/guides/prompt-caching - [2]
OpenAI, Batch API documentation, read December 2, 2026.
developers.openai.com/api/docs/guides/batch - [3]
DeepSeek, Models & Pricing, read December 2, 2026.
api-docs.deepseek.com/quick_start/pricing - [4]
NVIDIA Technical Blog, "Mastering LLM Techniques: Inference Optimization", published November 17, 2023, updated 2025, read December 2, 2026.
developer.nvidia.com/blog/mastering-llm-techniques-inference-optimization/ HIPS: the catalog of December 1, 2026; the Docs' Quickstart, Batch jobs, Prompt caching, Semantic routing, and Billing and credits.
See the cost of every request
Join early access. When your invitation comes, make a key, send one request and read its cost.