Optimize LLM API costs with prompt caching
Reduces input token costs by reusing cached prompt prefixes across conversation turns, with billing details visible in logs.
How it works
Read-onlyOperations and infrastructure
The agent analyzes API usage logs to identify conversations with high input token counts. It checks if the 'Affinity' field shows 'sticky' or 'explicit' and if 'Cached Input' tokens are significant. If the hit rate is low, it checks if the system prompt contains dynamic elements like timestamps that break caching. It suggests restructuring the prompt or adding session IDs to improve caching efficiency.
Prompt
Paste this into an agent that has the servers below connected. Adjust the names and dates to your own.
Prompt for Optimize LLM API costs with prompt caching
Analyze our recent API usage logs for the 'lovely-router-mcp' server. Identify conversations with high input token counts. Check if the 'Affinity' field shows 'sticky' or 'explicit' and if 'Cached Input' tokens are significant. If the hit rate is low, check if the system prompt contains dynamic elements like timestamps. Suggest how to restructure the prompt or add session IDs to improve caching efficiency.MCP servers it needs
Source
The vendor page this playbook is drawn from, and the passage that supports it.
Prompt caching lets a model reuse the work it did on a prompt prefix it has seen recently. Cached input costs a fraction of the normal input pricePrompt caching · Lovely Router Docs