Restructure Production Prompts for Cross-Provider Prompt Caching

Get a refactored prompt layout separating static prefixes from dynamic inputs, plus a token cache-hit savings table for OpenAI, Anthropic, and Gemini.

Text prompt for Claude and Gemini

You get: Cache-Breaking Issues Found, restructured Prompt Layout and cross-Provider Cache-Hit Table

Prompt

Prompt
Act as a staff LLM infrastructure engineer specializing in API cost optimization.

I will paste a production prompt and my approximate monthly request volume right after this message. Your job is to restructure the prompt so the static prefix maximizes prompt caching across OpenAI, Anthropic, and Gemini without changing the model output.

Follow these rules:
1. Move all immutable content (system role, rules, output schemas, few-shot examples, and reference docs) to the very top, and push all per-request variables (dates, user IDs, retrieved chunks, and user queries) to the bottom.
2. Flag any dynamic text currently embedded inside the static prefix that would invalidate cache hits.
3. Estimate the static prefix token count and check it against minimum caching thresholds: 1,024 tokens for OpenAI, 1,024 to 2,048 tokens for Anthropic Claude, and 1,024 to 4,096 tokens for Gemini.
4. Explain where to place Anthropic cache-control breakpoints and Gemini cached content boundaries in plain prose.

Output format:
- Cache-Breaking Issues Found: numbered list of dynamic elements polluting the prefix.
- Restructured Prompt Layout: ordered sections labeled Static Prefix and Dynamic Suffix.
- Cross-Provider Cache-Hit Table: Markdown table with columns for Provider, Minimum Threshold, Prefix Status, and Estimated Monthly Savings at 80% Hit Rate.

End with one line noting token-count assumptions and cache TTL expiration risks.

Example output

Monthly savings at 80% cache hit rateEstimated savings per provider on 450,000 requests per month
  • OpenAI (GPT-4o): $756
  • Anthropic (Claude Sonnet): $1,512
  • Gemini (2.5 Pro): $1,134

Example for: a B2B support triage prompt running 450,000 requests per month with a 1,650-token policy manual and 350-token customer tickets.

Cache-Breaking Issues Found
  1. Current UTC timestamp on line 2: Injecting the date at the top of the system prompt invalidates the entire prefix every minute.
  2. Customer account tier inside the rules block: Placing the plan name (Starter, Growth, Enterprise) before the 12 few-shot examples forces a full cache miss on every tier change.
  3. Unordered RAG snippets: Inserting retrieved knowledge-base articles before the output schema shifts token offsets on every call.
Restructured Prompt Layout
  • Static Prefix (1,680 tokens — cacheable):

    1. System role and escalation policy.
    2. Full 1,100-token refund and SLA policy manual.
    3. Output format rules and 12 labeled few-shot triage examples.
    • Breakpoint guidance: Place the Anthropic ephemeral cache-control marker immediately after the 12th few-shot example. For Gemini, store blocks 1 through 3 as the cached content object.
  • Dynamic Suffix (380 tokens — uncached):

    1. Current UTC timestamp and customer account tier.
    2. Top 3 retrieved knowledge-base snippets.
    3. Raw customer ticket body.
Cross-Provider Cache-Hit Table
ProviderMinimum ThresholdPrefix StatusEstimated Monthly Savings at 80% Hit Rate
OpenAI (GPT-4o)1,024 tokensQualifies (1,680 tokens)$756 / month (50% discount on cached input)
Anthropic (Claude Sonnet)1,024 tokensQualifies (1,680 tokens)$1,512 / month (90% discount after write fee)
Gemini (2.5 Pro)1,024–4,096 tokensQualifies for implicit; pad 400 tokens for explicit$1,134 / month (75% discount on cached input)

Assumptions and risks: Token counts are estimated at 4 characters per token; if traffic drops below 1 request every 5 minutes during off-peak hours, Anthropic and OpenAI caches will expire and incur full input write costs.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces strict separation of immutable prefix blocks from per-request variables so byte-exact cache keys actually hit.
  • Checks your static prefix against the real minimum token thresholds for OpenAI, Anthropic, and Gemini instead of guessing.
  • Produces a concrete monthly savings table at an 80% hit rate so you can justify the refactor to engineering leadership.

Use this when your LLM API bill is climbing from repeated system instructions or few-shot examples. Paste your current prompt and approximate monthly request volume into Claude, Gemini, or ChatGPT.

Common edits

  • Add your exact model names and per-million-token pricing if you use smaller tiers like GPT-4o mini, Claude Haiku, or Gemini Flash.
  • Ask for a second cache breakpoint after your tool definitions if your agent passes more than 10 function schemas.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Major AI ModelsClaude

Harden JSON Extraction with Strict Null and Fallback Rules

Get a hardened extraction prompt, strict schema specification, and edge-case test table that enforce null-over-guessing, enum fallbacks, and error handling.

Major AI ModelsClaude

Migrate Tool-Calling Schemas Across OpenAI, Claude, and Gemini

Convert your existing function definitions into native OpenAI, Anthropic Claude, and Google Gemini tool specs with a schema compatibility matrix.

Major AI ModelsClaude

Optimize Multi-Step Prompt Chains to Cut Latency and Spend

Get a before-and-after execution graph, parallelization plan, and token-cost breakdown to merge redundant LLM calls and cut prompt-chain latency.

Major AI Models

Calculate Context Window Budgets for Long-Document Prompts

Generates a token allocation plan across input docs, scratchpads, and outputs for ChatGPT, Claude, and Gemini to prevent context overflow.

Major AI ModelsClaude

Compress Production Prompts to Reduce Token Usage and Latency

Compress high-volume system instructions into concise directives, showing exact deletions and estimated token savings.

Major AI Models

Convert Complex System Prompts into Few-Shot Training Pairs

Transforms dense system instructions into five high-quality input-output pairs that clarify model expectations and edge-case handling.