Prompt Cache Misses: Cut Claude and GPT API Costs
Prompt caching can lower API costs when requests repeatedly include the same instructions, documents, examples, or tool definitions. The provider reuses a previously processed prompt prefix and charges eligible cached input at a reduced rate. The practical challenge is making requests qualify, then checking that the discount actually appears.
For developers using Claude Code, Codex, or an OpenAI SDK, combining effective caching with inexpensive API access can make repeated coding and document workflows more affordable.
Does prompt caching actually save tokens?
It usually reduces the cost of processing repeated input, rather than removing those tokens from your request. Cached content still occupies the model's context window. Output tokens are billed separately, and caching does not automatically shorten answers.
Keep three measurements separate: total input tokens, cached input tokens, and money charged. A request can contain exactly the same number of input tokens as before while costing less.
How do I structure a prompt for cache hits?
- Place stable material first: system instructions, tool definitions, reference documents, and reusable examples.
- Put changing material last: the current question, timestamps, request identifiers, and user-specific details.
- Keep the reusable prefix identical. Changes to whitespace, document order, or tool schemas can break a match.
- Send follow-up requests while the cache remains active. Expiration rules depend on the provider, model, and cache configuration.
For example, a support assistant should place its policy handbook before the customer's question. Inserting a fresh timestamp before the handbook changes the prefix and can prevent reuse of otherwise identical content.
How do Claude and GPT caching differ?
On supported Claude models, explicit caching uses cache_control on eligible content blocks. Set its type to ephemeral on the final block of the reusable section. The standard ephemeral cache lifetime is five minutes; a one-hour option is available where supported. Cache creation can cost more than ordinary input, so repeated reads must offset that initial premium.
Supported OpenAI models generally cache eligible prefixes automatically. Many require at least 1,024 prompt tokens before caching applies, with additional cached portions measured in increments. Minimum lengths and retention behavior vary by model. Check the documentation for your exact model instead of assuming one rule covers every Claude or GPT version.
Why are my cached tokens still zero?
- The prefix is too short. Count the stable portion, not just the complete request. A long changing question does not make a short reusable prefix eligible.
- Something changes near the beginning. Compare serialized requests, including system text, tool definitions, document formatting, and message order.
- The cache expired. Repeat the request promptly during testing, then measure realistic intervals between production requests.
- The model or route changed. Test with the same model identifier and credentials. Ask your relay whether routing preserves access to the same cache.
- The caching parameter was omitted. For explicit Claude caching, confirm that your client sends cache_control and that the relay forwards it.
How can I prove caching is working?
Send one request to establish the cache, then another with the same substantial prefix and a different final question. For Claude, inspect usage.cache_creation_input_tokens and usage.cache_read_input_tokens. For OpenAI Chat Completions, inspect usage.prompt_tokens_details.cached_tokens. The Responses API reports cached input under usage.input_tokens_details.cached_tokens.
Compare those counters with your billing records. Faster responses can accompany cache hits, but latency alone is weak evidence because network conditions and generation length also affect response time.
How much money can caching save?
Use your model's actual rates. As a hypothetical example, 10,000 reusable tokens cost $0.03 at $3 per million input tokens. At a cached rate of $0.30 per million, that same prefix costs $0.003 per cache hit. Account separately for uncached input, cache-write charges, output, and relay pricing.
Where does 59API fit?
59API offers low-cost, pay-as-you-go access to native, official-quality Claude and GPT models without model downgrades. It supports Claude Code, Codex, and OpenAI SDK workflows, with the API base URL https://api.59api.com. Its inexpensive access and referral rebate can complement caching savings; confirm cache support and billing for your selected model and route. Sign up for 59API and run the two-request test above to measure your own costs.
¿Listo para empezar?
Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.
Registro gratis