59API

← Voltar aos guias

Prompt Cache Misses: Cut Claude and GPT API Costs

Preços · EN · 2026-10-15

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?

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?

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.

Preços · Docs

Pronto para começar?

Conecte Claude e GPT em minutos pelos menores preços, sem cortes. Cadastre-se e obtenha sua chave API.

Cadastro grátis