Works with the AI Agents you already use
LLM App Cost Prompt Caching Optimizer
Audit LLM token spend and implement provider-specific prompt caching to reduce API costs.
$20
LLM App Cost Prompt Caching Optimizer
Example session with this skill installed
My Anthropic bill is spiking. I have a RAG app where users ask questions about a 50k token document set. I use Claude 3.5 Sonnet. Help me optimize for prompt caching.
- Read your context and instructions
- Compiled the llm app cost
I have analyzed your RAG application's spend profile. The 50k token document set represents a significant static prefix that is likely being re-processed on every turn, leading to massive redundant costs. ## LLM Cost Audit & Caching Plan | Metric | Current (Estimated) | Optimized (Projected) | | :--- | :--- | :--- | | **Input Tokens (Static)** | 50,000 | 50,000 (Cached) | | **Input Tokens (Dynamic)** | 500 | 500 | | **Cache Hit Rate** | 0% | 95%+ | | **Cost per 100 Requests** | $15.15 | $0.90 | ### Prompt Cache Redesign To trigger Anthropic's prompt caching, we must move the large document set into the `system` block or the early `messages` and mark it with a breakpoint. ```python import anthropic client = anthropic.Anthropic() # Optimized Request Skeleton response = client.messages.create( model="claude-3-5-sonnet-20240620", max_tokens=1024, system=[ { "type": "text", "text": "You are a helpful assistant. Use the following documents to answer...", "cache_control": {"type": "ephemeral"} }, { "type": "text", "text": "[50,000 tokens of static documentation here]", "cache_control": {"type": "ephemeral"} # Final breakpoint for the large doc } ], messages=[ {"role": "user", "content": "How do I configure the internal API?"} ] ) # Savings Verification # cache_read_input_tokens: 50000 # input_tokens: 500 ``` **Next steps** 1. Move all volatile bytes (timestamps, user IDs) to the very end of the message array to avoid breaking the cache prefix. 2. Monitor the `cache_read_input_tokens` field in your logs to verify a >90% hit rate. 3. Check the break-even point: at current pricing, if this document is requested more than twice an hour, caching is profitable.
Connects securely to your tools. The creator never sees your data.
About this skill
High token usage and inefficient request patterns drive up LLM API bills without improving quality. This skill audits your application architecture and prompt structure to implement aggressive, data-driven cost reduction strategies. ## What it does - **Cost Auditing** performs a detailed spend diagnosis across different request types to identify high-waste patterns. - **Cache Architecture** redesigns prompt structures to maximize prefix matches for Anthropic, OpenAI, and Gemini. - **Savings Quantification** computes break-even hit rates and projected monthly savings using verified cost formulas. - **Optimization Strategy** evaluates model routing, batch processing, and context hygiene to trim unnecessary tokens. - **Verification Planning** provides logging wrappers and hit-rate monitors to track real-world performance after deployment. ## How it works 1. **Intake** where the agent analyzes your provider, traffic shape, and prompt volatility to build a spend baseline. 2. **Diagnosis** where it ranks request types by monthly spend and classifies waste into specific anti-patterns. 3. **Redesign** where it outputs a corrected request skeleton with explicit cache breakpoints and optimized prefix order. 4. **Modeling** where it runs calculations to show the delta between current and projected unit costs. ## Frameworks & tools Python-based cost calculators, provider-specific API implementations for Anthropic (cache_control), OpenAI (automatic caching), and Google Gemini (context caching). ## Why this beats prompting it yourself Generic prompts often ignore provider-specific minimum cacheable lengths and break-even hit rates, leading to higher costs from unnecessary cache writes. This skill applies specific arithmetic to prove if a caching strategy is actually profitable before you write a single line of code. ## Use cases - Reducing a high monthly Anthropic or OpenAI bill by optimizing stable system prefixes. - Designing a multi-turn conversation cache to minimize redundant input processing. - Auditing tool-schema bloat in agentic workflows to improve cache hit rates. - Comparing model-routing vs. batching for high-volume, non-interactive tasks. ## Known limitations Does not provide real-time price tracking; users must provide current API pricing. Requires manual verification of provider-specific TTL and minimum length updates.
Requires user-provided pricing for accurate modeling. Cannot fix application-level logic errors. Caching recommendations depend on exact prefix matches.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 18 days ago