August 4, 2026
13 Expert Tactics to Reduce OpenAI API Costs in 2026
Learn 13 proven tactics to reduce OpenAI API costs in 2026—compress context, cache prompts, route to cheaper models, and use Batch for 50% off.

TL;DR
Most OpenAI API cost waste comes from three sources: irrelevant input tokens, verbose output tokens, and unnecessary API calls. The fastest way to reduce OpenAI API costs depends on your workload. Compress dynamic context for RAG and agent pipelines, use prompt caching for repeated static prefixes, route simple tasks to cheaper models, cap outputs, and batch async work for a 50% discount. This guide ranks 13 tactics by expected savings, difficulty, and quality risk so you can start with the one that actually moves your bill.
How to Reduce OpenAI API Costs (Quick Summary)
To reduce OpenAI API costs, implement a combination of token compression, model routing, and API discounts:
-
Compress Context: Remove non-essential tokens from RAG payloads, search results, and chat history for a 40% to 80% input token reduction.
-
Enable Prompt Caching: Place static system prompts at the beginning of requests to get a 50% discount on cached input tokens.
-
Use Model Routing: Move simple classification, extraction, and formatting tasks from flagship models to smaller models like GPT-4o-mini for over 90% cost savings per request.
-
Leverage the Batch API: Process non-real-time evaluations, embeddings, and background jobs asynchronously for a flat 50% discount.
-
Cap Output Tokens: Enforce strict answer limits using
max_tokensparameters and concise output schemas to control high-cost generation.
Why Your OpenAI Bill Jumped
Your prototype cost $2 a day. Then you added RAG, File Search, tool calls, and chat history, and suddenly you were looking at $200. This is the most common path to an OpenAI cost problem, and it catches teams off guard because per-token prices look small until you multiply by volume.
A developer on the OpenAI Community forum described exactly this. Their RAG chatbot using GPT-4o and File Search cost about $0.20 for just 10 user questions. They were terrified of scaling to 10,000 users. The thread reveals the core issue: each request carried retrieved chunks, chat history, tool calls, and agent-loop overhead that ballooned token counts far beyond the user’s actual question.
OpenAI’s own cost optimization guide frames the solution around three core levers: reduce requests, minimize tokens, and select smaller models. But the right combination depends on whether your cost driver is long RAG context, expensive outputs, repeated prompts, or unnecessary tool calls.
This guide covers 13 practical tactics to reduce OpenAI API costs, ranked by ROI and implementation difficulty. Each section includes expected savings, tradeoffs, and real practitioner evidence.
Try a free compression demo to see how much of your prompt context is actually needed.
At-a-Glance Comparison
Strategy | Primary Mechanism | Expected Savings | Implementation Effort | Best Used For |
Context Compression | Trims filler tokens from dynamic prompts | 40% – 80% input tokens | Medium | RAG pipelines, long chat history, tool outputs |
Model Routing | Replaces heavy models with smaller alternatives | 80% – 95% unit price | Medium | Simple intent routing, classification, formatting |
Prompt Caching | Reuses identical prompt prefixes | 50% cached input discount | Low | Fixed system prompts, static knowledge |
OpenAI Batch API | Processes non-urgent jobs within 24 hrs | 50% flat discount | Low | Async processing, offline evaluations, backfills |
Output Constraints | Restricts max completion lengths | 30% – 70% output tokens | Low | Structured extraction, JSON formatting |
Response Caching | Bypasses LLM for identical queries | 100% per cache hit | Medium | FAQ bots, high-volume repetitive queries |
How OpenAI API Pricing Actually Works
Before optimizing anything, understand the cost formula:
Total cost =
(input_tokens × input_price)
+ (cached_input_tokens × cached_price)
+ (cache_write_tokens × cache_write_price)
+ (output_tokens × output_price)
+ tool fees + storage fees + retry overhead
Official OpenAI Token Pricing Benchmark (per 1M Tokens)
Model Tier | Standard Input | Cached Input (50% Off) | Standard Output |
GPT-4o | $2.50 | $1.25 | $10.00 |
GPT-4o-mini | $0.15 | $0.075 | $0.60 |
o3-mini | $1.10 | $0.55 | $4.40 |
Notice that output tokens cost 4x the uncached input price on GPT-4o and o3-mini. Furthermore, cached input provides a 50% discount on qualifying requests, making prompt caching essential for long, static prompts that repeat across requests.
All three models offer a 1.05M context window. That is not an invitation to fill it. OpenAI’s GPT-5.4 documentation notes that prompts exceeding 272K input tokens trigger long-context premium pricing: 2× input and 1.5× output for the full session. Big windows carry big bills if you are not careful.
With this pricing context, here are 13 ways to cut your OpenAI API spend, starting with the step every team should take first.
1. Audit Usage by Workflow
Best for: Every production app before making any other changes.
You cannot optimize what you do not measure. The most common mistake is tweaking prompts on a workflow that represents 5% of spend while ignoring the one behind 80%.
What to log per request:
-
Model, endpoint, and workflow name
-
Input tokens, cached tokens, cache-write tokens, output tokens
-
Tool calls and retries
-
Latency, cost estimate, and user/session ID
OpenAI’s Usage Dashboard supports project filtering, cost exports, and TPM-level granularity. For programmatic access, the Costs API returns aggregated spend grouped by project and line item.
Build a “cost per successful task” metric, not just “cost per request.” For agents, a single user action can trigger dozens of internal calls. Cost-per-request hides the real picture. For a deeper framework on structuring this metric, see this breakdown of AI cost per task.
Tradeoffs:
-
Dashboards reveal symptoms, not root causes. You still need request-level traces to understand why one request consumed 40,000 input tokens.
-
Cost-per-user metrics mislead for agent workflows where one action spawns many API calls.
-
Proper observability takes a day or two to set up, but every optimization tactic after this becomes measurable.
A practitioner on Reddit who reported spending billions of OpenAI tokens in a single month emphasized that billing alerts were essential after hitting their budget far faster than expected.
Do this first. Every other tactic should be judged by measured cost per successful task.
2. Compress Long Dynamic Context
Best for: RAG apps, agents, and pipelines with long, variable input context that changes every request.
If your prompt contains RAG chunks, search results, tool outputs, chat history, SEC filings, contracts, or Markdown documents, the highest-leverage fix is often sending fewer relevant tokens rather than switching models.
This is context compression: removing spans irrelevant to the current query while preserving the evidence the model needs for an accurate answer.
The research supports the approach strongly. NEC’s LeanContext system, a query-aware context reducer, cut LLM API costs by 37–68% compared to baselines. Microsoft’s LLMLingua work reports up to 20× compression with little performance loss across several benchmark datasets. A 2026 arXiv study on prompt compression in real-world inference found up to 18% end-to-end speedups with response quality statistically unchanged.
Compression break-even math:
At Compresr’s hosted API price of $0.10 per 1M tokens compressed, the math is favorable. For uncached GPT-5.6 Sol input at $5.00/M, compression breaks even with just a 2% token reduction. For Terra at $2.50/M, you need 4%. Even Luna at $1.00/M breaks even at 10%.
Actual ratios are much higher than these thresholds. Compresr’s FinanceBench example shows roughly 2× compression with their latte_v2 model, achieving 77% accuracy versus 73% baseline and about 47% cost savings. A Boeing 10-K demo compressed 112,552 tokens down to 498, cutting cost by 86%.
Concrete cost example (GPT-5.6 Terra):
-
Original dynamic context: 40,000 tokens
-
OpenAI cost before compression: $0.10
-
Compression processing cost: $0.004
-
After 60% reduction, OpenAI sees 16,000 tokens: $0.04
-
Total after compression: $0.044 (56% input-side savings)
Implementation:
-
Add compression before the OpenAI call for RAG chunks, web-search snippets, chat history, and large tool outputs
-
Use query-aware compression so the compressor keeps evidence relevant to the current question
-
Skip compression for contexts under roughly 500 tokens, where API overhead may outweigh gains
-
Run evals at light, medium, and aggressive compression ratios to find the sweet spot
-
Store both original and compressed token counts for ROI tracking
Practitioners on Reddit report significant savings. One builder using quality-gated semantic compression saved about 47,000 tokens per day with roughly 60% reduction. Another on r/LocalLLM noted around 80% cost reduction on API calls for some tasks, though they flagged friction around chunking inputs for the compression model’s sequence length.
See current pricing and free credits to test compression on your own prompts.
Tradeoffs:
-
Over-aggressive compression can remove critical evidence. Always eval-gate your chosen ratio.
-
Adds an extra processing step (API call or local inference).
-
Less useful for tiny prompts or static prefixes that already hit prompt caching.
If your prompt changes every time, prompt caching will not save you. Compress dynamic context before you pay OpenAI to read it.
3. Route Requests to the Cheapest Capable Model
Best for: Mixed workloads where many subtasks don’t need frontier reasoning.
Not every API call deserves your most expensive model. Moving a classification task from GPT-5.6 Sol ($5.00/M input, $30.00/M output) to Luna ($1.00/M input, $6.00/M output) is a 5× unit-price reduction on both sides.
How to route:
-
Simple classification, formatting, extraction, yes/no routing → cheapest model
-
Moderate reasoning and summarization → mid-tier model
-
Critical reasoning, legal analysis, complex code → frontier model
-
Route based on query type, required evidence, risk level, and expected output length
In a guide on agent token reduction, MindStudio identifies model routing as one of the highest-leverage strategies because most agent subtasks are simpler than the hardest step. Practitioners on Reddit confirm this: a cheap fast model works well as a router when the decision boundary is simple and clearly defined.
Tradeoffs:
-
A bad router silently degrades quality. You need evals per route.
-
Some tasks look simple but require domain judgment. Start conservative.
-
Fallback logic is essential: if the cheap model fails or expresses low confidence, escalate.
The cheapest token is the one you do not send. The second cheapest is the one you send to the right-sized model.
4. Use Prompt Caching for Repeated Static Prefixes
Best for: Apps with large, repeated system prompts and static instructions.
Prompt caching is a low-effort win when many requests share the same long prefix. Cached input reads on GPT-5.6 are 90% cheaper than uncached input, and caching activates automatically for prompts of 1,024 tokens or longer.
Implementation:
-
Put static content first: system prompt, tool schemas, output schema, reusable instructions
-
Put dynamic content last: user message, retrieved chunks, timestamps
-
Monitor
cached_tokensandcache_write_tokensin API responses -
Track cache hit rate as a core operational metric
Important 2026 update: GPT-5.6 cache writes now cost 1.25× the uncached input token rate. This is a change from earlier models. If your prompt prefix changes often enough that most requests trigger writes instead of reads, you are paying more than uncached prices for those tokens. Reddit developers have flagged confusion around this, and the advice is simple: inspect prompt_tokens_details before trusting migration math.
Prompt caching also does not reduce token volume. Cached prompts still count toward TPM rate limits. Caching makes repeated prefixes cheaper, but it does not help when every request carries different retrieved context. For a detailed breakdown of when caching wins versus when compression wins, see prompt caching vs compression.
Tradeoffs:
-
Exact-prefix matching is brittle. Any prefix change busts the cache.
-
Cache-write fees on GPT-5.6 can add cost if dynamic content leaks into the prefix.
-
Does not reduce output tokens or shorten actual context length.
Prompt caching is not compression. It discounts repeated prefixes. It does not shrink your dynamic context.
Prompt Caching vs. Context Compression: Which Should You Use?
While both strategies target input token costs, they operate differently and solve distinct architectural problems:
-
Prompt Caching works on static, exact-matching text. It is ideal when you send the same system prompt or instructions across thousands of API calls. It reduces input costs by 50% without changing the actual text or reducing the total token count sent to the model context window.
-
Context Compression works on dynamic, changing context. It analyzes RAG search results, agent logs, or chat histories on the fly and strips away redundant words or irrelevant paragraphs. It reduces the total token count before sending the request to OpenAI.
Comparison Matrix
Feature | Prompt Caching | Context Compression |
Target Data | Static system prompts & fixed instructions | Dynamic RAG chunks, search results, variable history |
Token Reduction | 0% (Tokens remain in payload) | 40% – 80% reduction in context window usage |
Cost Discount | 50% on cached inputs | Equivalent to percentage of tokens removed |
Rate Limit Impact | Tokens still count toward TPM limits | Reduces overall TPM footprint |
5. Add a Pre-Check Before RAG or File Search
Best for: Knowledge-base chatbots where many user queries don’t actually need retrieval.
Many user messages are greetings, follow-ups, or general questions the model can handle without your vector store. A cheap classifier deciding whether to call RAG can eliminate unnecessary retrieval entirely.
A practitioner on Reddit shared that adding a simple yes/no pre-check (“Does this query require case-law context?”) before File Search reduced their RAG costs by 70% and made the product economically viable. The extra call was fast because it only returned a binary answer, and the product (legal document generation) could tolerate a small delay.
Implementation:
-
Pre-check prompt: “Does this query require the knowledge base? Return
needs_retrieval: true/falsewith a short reason.” -
If false, answer with general model knowledge or ask a clarifying question
-
If true, run retrieval, compress results, and answer with citations
-
Add confidence thresholds: low confidence should default to retrieval
-
In regulated domains, retrieve by default
Tradeoffs:
-
False negatives are dangerous: skipping retrieval produces unsupported answers.
-
The classifier itself costs tokens, though far fewer than a full RAG call.
-
Requires eval data for “should retrieve?” decisions.
Before optimizing RAG, ask whether each query needed RAG in the first place.
6. Tune Retrieval So OpenAI Sees Fewer, Better Chunks
Best for: RAG systems returning too many overlapping or irrelevant chunks per query.
RAG cost is often a retrieval quality problem. If your vector search returns five chunks with 50% overlap, you are paying OpenAI to read the same information multiple times.
In the OpenAI Community thread mentioned earlier, the developer used max_num_results=5, max_chunk_size_tokens=800, and chunk_overlap_tokens=400 (OpenAI’s defaults). A community reply warned that File Search can inject around 15,000 tokens of documentation chunks into the thread, and model/tool loops can push totals to 20,000 or 30,000 tokens.
What to do:
-
Reduce
top_kormax_num_resultswhere answer quality allows -
Lower chunk overlap if documents are repetitive
-
Add reranking to improve relevance before generation
-
Compress retrieved chunks before passing them to OpenAI (see the RAG compression guide for implementation patterns)
-
Deduplicate overlapping chunks
-
Strip boilerplate, navigation, footers, and repeated headings from source documents before indexing
The same community thread noted that Arabic-language content cost more tokens than English, a reminder that non-Latin scripts often tokenize less efficiently. This makes retrieval tuning and compression even more important for multilingual RAG.
Tradeoffs:
-
Too few chunks can hurt recall. Test with your actual question set.
-
Reduced overlap can split evidence across chunk boundaries.
-
Reranking adds latency and infrastructure complexity.
RAG should make prompts smaller than the corpus, not turn every answer into a mini corpus dump.
7. Cap Output Tokens and Reasoning Effort
Best for: Extraction, classification, and structured data tasks where verbose prose is unnecessary.
Output tokens are the silent cost killer. On GPT-5.6, output costs 6× the uncached input price across all tiers. A 2,000-token output on Sol costs $0.06, the same as 12,000 input tokens. Many teams focus entirely on reducing input while ignoring output.
What to do:
-
Set
max_output_tokensto enforce hard limits -
Use concise answer contracts: “Answer in 3 bullets,” “Return only JSON,” “If evidence is insufficient, say
insufficient_evidence” -
Use structured outputs for extraction and classification
-
Set
reasoning.effortto low or none for simple tasks where evals show no quality difference -
For internal model-to-model communication in agents, use compact schemas instead of prose
A high-volume Reddit user reported that switching from full-text outputs to compact position numbers and categories cut their output tokens by roughly 70%. Another community discussion cautioned that minified JSON does not always save as many tokens as expected because BPE tokenization handles whitespace differently than you might guess. The advice: test with a tokenizer, do not assume.
Tradeoffs:
-
Overly tight caps can truncate useful answers. Set limits based on task requirements, not arbitrary numbers.
-
Structured outputs feel unnatural for explanatory or conversational tasks.
-
Lower reasoning effort may hurt complex multi-step problems. Run evals before reducing.
Do not pay frontier output-token prices for paragraphs your software will throw away.
8. Use Batch API for Non-Urgent Jobs
Best for: Async jobs like evals, embeddings, document tagging, and nightly data enrichment.
If nobody is waiting for the result, do not pay synchronous prices. OpenAI’s Batch API provides a flat 50% cost discount with a 24-hour completion window. A single batch can include up to 50,000 requests with input files up to 200 MB.
Good candidates for batching:
-
Eval runs and model comparisons
-
Offline classification and tagging
-
Embedding backfills
-
Summarizing document archives
-
Nightly data enrichment
-
Synthetic data generation
High-volume Reddit practitioners consistently call Batch API one of the cleanest wins for reducing OpenAI API costs, with one describing it as a “godsend” for non-real-time work.
Tradeoffs:
-
Not suitable for interactive user experiences.
-
Requires job orchestration and partial-completion handling.
-
Some community reports mention batch billing anomalies at high volume. Reconcile batch costs against exports.
If users are not waiting, do not pay synchronous prices.
9. Use Flex Processing for Low-Priority Work
Best for: Low-priority background analysis and non-production workloads.
Flex processing gives you Batch API rates on synchronous-style calls, trading speed and availability for lower cost. Set service_tier: "flex" on eligible requests, increase client timeouts, and use exponential backoff on resource-unavailable errors.
OpenAI recommends Flex for non-production tasks: model evaluations, data enrichment, and asynchronous internal workloads. Flex tokens can also receive prompt-caching discounts, stacking savings from both strategies.
Tradeoffs:
-
Slower response times, sometimes significantly so.
-
May return resource-unavailable errors during peak demand.
-
Currently in beta with limited model availability.
-
Not appropriate for user-facing paths where latency matters.
Flex is a cost tier, not a UX tier.
10. Move Tool Outputs and State Out of the Prompt
Best for: Long-running agents and multi-turn chat sessions with growing context.
Agents get expensive because they accumulate history. Every tool call result, search output, code execution log, and past conversation turn gets appended to the prompt. The model re-reads all of it on every step.
MindStudio’s guide identifies conversation history, tool outputs, and system prompts as the major sources of context bloat in agents. Tool outputs from APIs, web search, or file reads can add thousands of tokens per call, and multi-turn history can reach 15,000 or more tokens after just 10 turns.
What to do:
-
Store tool results, logs, intermediate artifacts, and older chat turns in a database
-
Retrieve only what the current step needs
-
Summarize older conversation turns with rolling summaries
-
Compress old tool outputs before storing or re-injecting them
Teams using LangChain can integrate compression directly into their agent chains. The LangChain integration provides middlewares for compressing tool outputs, chat history, and managing prompt budgets within existing workflows.
A practitioner building agentic systems on Reddit described compressing old tool results during tool calls and reported dramatic context-size reductions, particularly for irrelevant or dead tool results.
Tradeoffs:
-
Requires architecture changes, sometimes significant ones.
-
Retrieval from external memory can fail or return stale data.
-
Rolling summaries can drift from original facts over time.
-
Need clear state schemas and traceability for debugging.
Your prompt is not a database. Store state where databases live.
11. Cache Full or Semantically Similar Responses
Best for: FAQ bots and support assistants with repetitive user queries.
Prompt caching discounts input tokens. Response caching can skip the OpenAI call entirely. If 30% of your users ask the same five questions, caching the answers means those requests cost nothing after the first call.
Two approaches:
-
Exact cache: Same normalized input, same model, same system prompt version, return stored answer
-
Semantic cache: Embed the user query, find similar prior queries above a similarity threshold, return the cached answer if freshness requirements are met
Practitioners on Reddit note that traditional exact caching is weak for natural language because users phrase the same question differently. Semantic caching handles this by matching on meaning rather than exact text.
Tradeoffs:
-
Stale answers are dangerous, especially for time-sensitive information.
-
Permission boundaries matter in multi-tenant apps.
-
Semantic cache false positives can return wrong answers. Use conservative similarity thresholds.
Prompt caching makes repeated prefixes cheaper. Response caching makes repeated questions free.
12. Control File Search and Vector Store Costs
Best for: Apps using OpenAI’s hosted vector stores and File Search tool.
OpenAI RAG cost is not only generation tokens. File Search storage is priced at $0.10 per GB per day of vector store storage, with the first GB free. This seems small but accumulates across multiple stores, duplicate uploads, and forgotten test data.
What to do:
-
Delete unused vector stores and set expiration policies
-
Track
usage_byteson vector store objects -
Avoid duplicate file uploads
-
Pre-clean documents before upload: strip boilerplate, navigation, footers
-
Monitor File Search calls per conversation
-
Compare hosted File Search versus custom RAG when cost control matters more than convenience
A community reply on the OpenAI Forum advised that if budget and specialization are major concerns, building with Chat Completions and your own retrieval solution offers more control than semi-autonomous tools like File Search.
Tradeoffs:
-
Custom RAG requires engineering investment.
-
OpenAI File Search can be higher quality out of the box than a naive vector search.
-
Storage fees are often small relative to token waste, but they add up for multi-tenant apps.
Hosted RAG is convenient. Cost-optimized RAG needs governance.
13. Set Budgets, Alerts, and Cost Evals
Best for: Production governance and preventing runaway spend.
Cost optimization should be a release criterion, not a panic response after a bill spike.
What to set up:
-
Budget alerts at 50%, 80%, and 100% of expected spend
-
Hard spending limits where available (verify whether your project limit is alert-only or enforced, as behavior varies)
-
Alerts on cost-per-user spikes, output-token spikes, retrieval-call spikes, cache hit-rate drops, and retry-count increases
-
CI/eval checks for expected tokens per test case, max cost per task, and quality scores
-
A “kill switch” for expensive tools or models that can be triggered without a deploy
OpenAI’s project management settings allow budget thresholds and model-usage controls, but teams should confirm whether their limits actually block requests or simply send notifications.
Tradeoffs:
-
Alerts do not reduce cost by themselves. They buy you time to respond.
-
Soft budgets will not stop traffic. Hard limits can break user workflows without graceful fallback.
-
Cost evals need representative test cases, which require upfront investment.
Cost controls are reliability controls.
Which Tactic Should You Try First?
The right starting point depends on what is driving your bill:
-
Long dynamic context (RAG docs, tool outputs, chat history)? Start with context compression.
-
Repeated static prompt prefix? Enable and measure prompt caching.
-
Output tokens dominating cost? Cap outputs and use structured schemas.
-
Async jobs running at synchronous prices? Move them to Batch API or Flex.
-
File Search called when not needed? Add a retrieval pre-check.
-
Simple tasks on expensive models? Add model routing.
-
Not sure what the driver is? Run a usage audit first.
These tactics stack. A team might cache their system prompt, compress their RAG context, route simple classifications to Luna, and batch nightly evals. Each layer compounds the savings.
For teams whose OpenAI spend is driven by long, dynamic context that changes too often for prompt caching, query-aware compression is typically the highest-ROI starting point.
For enterprise or regulated workloads requiring on-prem deployment, contact the Compresr team to discuss volume pricing and data-residency requirements.
Frequently Asked Questions
What is the fastest way to reduce OpenAI API costs?
It depends on the cost driver. For repeated static prefixes, prompt caching is the quickest win. For long dynamic context (RAG, chat history, tool outputs), query-aware compression delivers the largest input-token reduction. For async workloads, Batch API provides a flat 50% discount with minimal code changes.
Does prompt caching reduce token count?
No. Prompt caching discounts the price of cached input tokens (up to 90% off) but does not reduce the number of tokens in the prompt. Cached tokens still count toward TPM rate limits. If you need to shrink actual token volume, you need compression or shorter prompts.
Is prompt compression safe for production use?
When properly eval-gated, yes. Research from NEC and Microsoft shows query-aware compression can reduce context by 37–68% or more with little or no performance loss. The key is testing at your chosen compression ratio with representative queries and measuring answer quality, not just token savings.
Should I use Batch API or Flex processing?
Use Batch API for jobs that can wait up to 24 hours: evals, embeddings, classification, data enrichment. Use Flex processing for lower-priority synchronous calls where you want Batch-rate pricing but need a response sooner. Both offer significant discounts, but Flex has availability limitations during peak demand.
Why is my RAG chatbot so expensive?
Because each request can include system instructions, chat history, multiple retrieved chunks, tool calls, and internal agent-loop steps. In OpenAI Community discussions, developers report File Search adding 15,000 or more tokens of documentation chunks per thread, with model/tool retries pushing totals even higher. The fixes: tune retrieval, add pre-checks, compress retrieved context, and manage chat history.
How do I calculate whether compression pays for itself?
Compression saves money when the reduction in OpenAI input cost exceeds the compression processing cost. At $0.10/M tokens for compression and $5.00/M for GPT-5.6 Sol input, even a 2% reduction breaks even. At typical compression ratios of 40–60%, the savings are substantial across all GPT-5.6 tiers.
Is it cheaper to use a smaller model or compress context?
Both approaches work, and they complement each other. Model routing reduces per-token price (5× savings moving from Sol to Luna). Compression reduces the number of tokens sent (often 40–90% for long context). You can stack them. A team processing 40,000 dynamic input tokens can route to a cheaper model and compress the context, compounding savings from both levers.
Do I need to rebuild my app to lower OpenAI API costs?
Not necessarily. Several tactics require minimal code changes: prompt caching works automatically for eligible prompts, Batch API needs a job wrapper, output caps are a parameter change, and budget alerts are configured in the dashboard. Context compression can be added as a middleware step before the OpenAI call. Deeper changes like model routing, external memory, and retrieval tuning require more architecture work but deliver proportionally larger savings.