How to Quote OpenAI Accurately: A Guide to Cache-Aware Prompts
Most teams treat OpenAI costs like a mystery bill. They build something, it works, and then the invoice arrives with a number nobody predicted. The problem usually isn't the model choice or the workload size. It's that nobody designed the prompts with the cache window in mind.
OpenAI's prompt cache is one of the most useful cost-control tools available right now, and it's almost entirely ignored in how-to content. With Terra and Luna now in the mix, quoting an OpenAI project accurately requires understanding three things together: which model to use, how the cache window applies, and how to write prompts that stay inside it deliberately. This guide covers all three, with templates you can copy today.
Understanding OpenAI's Prompt Cache Window
OpenAI caches prompt prefixes so that repeated identical input doesn't get reprocessed from scratch. When the same prompt prefix hits the API again within the cache window, the cost and latency drop meaningfully. But "identical" means exactly that. One extra space, one changed comma, and the cache misses. You're billed in full.
Cache retention varies by deployment context and can shift over time, so treat the window as something to test on your specific setup rather than a number to assume. What doesn't change is the mechanic: identical prompt text, sent within the retention window, gets the discount. Everything else pays full price.
For teams, consistent prompt structure matters across the board. Standardizing on a shared prompt library and coordinating how requests are routed gives you the best shot at cache hits compounding across the whole workflow rather than fragmenting across different variations of the same instruction.
Here's what ignoring this looks like in practice. A team summarizing 50 news articles each morning runs each article through the same summarization prompt, one at a time, with slight rewording each run. Every call costs full price. Here's what deliberate cache design looks like instead:
Before (no cache awareness):
Summarize this article and highlight the three most important points: [article text]
After (cache-breakpoint design):
[SYSTEM: Stable summarization prompt — do not modify this text] Summarize this article and highlight the three most important points: [article text]
Locking the static portion of the prompt means the prefix is byte-for-byte identical on every call. The variable article text goes at the end. That's the mechanic. Now you need to build prompts that exploit it on purpose.
Terra vs Luna: Which Model Fits Your Workflow
Terra and Luna are part of OpenAI's newer model lineup, currently available in preview. Treat their positioning as a guide rather than a locked-in guarantee, and test behavior on your specific deployment before committing cost projections to them.
Terra is the practical default for production work. If you're running pipelines, daily automations, or anything that processes the same type of input repeatedly, Terra is the right starting point. It's built as an everyday workhorse, balancing capability and reliability for the kinds of tasks that run consistently in the background.
Luna is built for speed and lighter-weight tasks. It handles rapid prototyping and high-throughput simple requests well. For short bursts of iteration where turnaround time matters more than raw reasoning depth, Luna earns its place.
And here's the cost angle most people overlook: Luna is the lower-cost option per token, making it genuinely attractive for high-volume, lower-complexity work where you don't need Terra's heavier capability. Before building projections, check OpenAI's pricing page for current figures on both models. The right model choice isn't just about what the model can do; it's about matching capability to task so you're not paying for horsepower you don't need.
Here's how to think about that split in practice. Say you're summarizing a batch of articles with a stable summarization prompt. On Terra, you're paying for strong reasoning quality on every call. If the task is genuinely complex or the output is going straight into production, that cost is justified. If the task is simpler and volume is high, Luna's lower per-token cost compounds across the batch. Cache hits reduce cost meaningfully on both models, but they don't make repeat calls free. The Terra/Luna price gap matters most when cache misses happen frequently, which is exactly what poor prompt design causes.
The practical rule: use Terra for anything that demands consistent reasoning quality, especially in production. Use Luna when you're running high volumes of simpler tasks or iterating rapidly and turnaround speed is the priority. Don't mix them in the same workflow unless you're tracking costs by stage.
5 Cache-Breakpoint Templates You Can Paste Today
Each template below structures your prompt so the static instruction prefix is identical across calls. The variable content goes at the end, after the fixed portion. That structure is what creates consistent cache hits on the prefix. Your downstream system handles the rest.
A note before you copy: these are prompt-side conventions that help you hit the conditions for a cache hit. They don't give you direct API-level control over the cache. What they do is make your prompts structurally consistent, which is the thing the cache actually rewards.
Adapt the placeholder text to your actual task. The structure is what matters.
Template 1: General-Purpose Stable Prefix
[SYSTEM: Do not modify the text above this line.] [Your fixed task instruction here.] Input: [variable content here]
Template 2: Session-Scoped Task with Time Boundary
[SYSTEM: Stable instruction block — batch all requests within one session window.] [Your task instruction here.] Input timestamp: [timestamp] | Content: [variable content]
Use this when you want explicit control over batching boundaries, especially for workflows that run on a timer. The timestamp goes in the variable portion, not the fixed prefix.
Template 3: Summarization with Stable Prefix
[SYSTEM: Summarization prompt v1 — do not modify.] Summarize the following article and highlight the three most important points. Article: [article text]
Template 4: Translation with Stable Prefix
[SYSTEM: Translation prompt — target language: [target language] — do not modify above.] Translate the following text to [target language]. Text: [text]
Template 5: Code Generation with Stable Prefix
[SYSTEM: Code generation prompt v1 — do not modify.] Generate code that [fixed specification description]. Additional context: [variable context]
These work best when you standardize the prompt text across your team. One person rewording the instruction slightly breaks the cache on the prefix. The solution is treating these templates as locked strings, not loose guidelines. Version-control them like you would a system prompt.
If you want to go further with structured prompt design, the best AI users aren't coders, they're communicators — and the same principle applies here. Precise, repeatable language is the skill that makes cache-aware prompts work.
The Batching Strategy That Keeps You Inside the Window
The cache window doesn't just reward identical prompts. It rewards timing. You can have a perfect stable prefix and still miss every hit if your requests are spaced too far apart.
Here's a three-step batching approach that keeps costs predictable:
- Step 1: Audit your repetitive tasks. Identify any workflow where the same prompt structure runs more than once per session. Article summaries, translation batches, code boilerplate generation, daily report formatting. These are your batching candidates.
- Step 2: Group requests by type and send them together. Instead of processing articles one by one across the day, queue them and send the batch within a single session window. The first call in the batch pays full price. Every identical-prefix repeat within the cache window gets the discount.
- Step 3: Standardize your prompt strings. Build a shared prompt library your team pulls from, not a mental template each person rewrites from memory. Every character in the fixed prefix counts. A shared library is the most reliable way to keep prompt text consistent and give the cache the identical input it needs to fire.
For teams managing a mix of workflows, it's worth thinking through which tasks belong in Terra's production track versus Luna's faster, lighter iteration track before you commit to a batching structure. Getting that split right means the cache works hardest where it matters most. This is also where thinking carefully about what you hand to AI versus what you own yourself pays off — batch the repeatable work, and spend your attention on the decisions that need your judgment.
One more thing worth tracking: OpenAI adjusts pricing tiers. A batching strategy built around today's numbers should be revisited when those numbers change. Set a calendar reminder to check pricing quarterly. The templates stay the same; the math might not.
Frequently Asked Questions
How do I improve my chances of getting cached responses in my prompts?
You can't force a cache hit from outside the API, but you can guarantee the conditions for one. Your prompt prefix must be byte-for-byte identical to the previous request, sent within the cache retention window, with consistent routing setup. The templates above are designed to help you hit those conditions reliably. Standardize the prompt string, lock it across your team, and batch the requests tightly.
What is the real cost difference between Terra and Luna for daily work?
Luna is the lower-cost model per token, which makes it the more economical choice for high-volume, lower-complexity tasks. For daily repetitive work involving simpler outputs, Luna with good batching and cache hygiene can meaningfully reduce API spend compared to running everything through Terra. Terra earns its higher per-token cost when you need stronger reasoning quality for complex, production-grade tasks. Check OpenAI's pricing page for current figures on both models, then match the model to the complexity of the task.
Can I batch prompts to stay inside the cache window?
Yes, and this is one of the most effective cost-reduction strategies available. Group similar requests by type, standardize the prompt strings, and send them within a single batching window. The first call pays full price. Identical-prefix repeats within the window get the cache discount. For high-volume workflows, this can cut API spend meaningfully.
Is there a template for cache-aware prompt design?
The five templates in this article are a starting point. Each one locks the static instruction as a stable prefix and pushes variable content to the end of the prompt. That structure is what creates consistent cache hits. They cover general tasks, time-windowed batching, summarization, translation, and code generation. Copy them, adapt the task description, and lock the string across your team.
Does the cache window work the same way across all OpenAI models?
Cache retention can vary by model, deployment tier, and over time. Always test cache behavior on the specific model you're deploying before building your cost projections around it. What works reliably on Terra may behave differently on Luna given its different architecture and use-case positioning. Test first, then budget.
Accurate quoting isn't about knowing OpenAI's price list. It's about designing prompts that make costs predictable in advance. The cache window, the Terra/Luna split, and tight batching give you that control. Use all three together and the budget surprises mostly disappear.
If you want structured templates built around these principles, Ultra Prompt's prompt library has structured templates built for exactly this kind of deliberate, repeatable prompt design.