59API

← Retour aux guides

Cache Reads: Cut Costs on Repeated AI Prompts

Tarifs · EN · 2026-10-21

The quick answer: cache the context you keep sending

Use cache reads when requests repeatedly send a substantial, identical prompt prefix: system instructions, tool definitions, reference documents, or an existing conversation. The provider can reuse previously processed input and, where supported, bill those tokens at a lower cache-read rate.

This is prompt caching, not response caching. The model still generates a new answer. You save on eligible input processing, not output tokens, and you still need to send the required context unless the API explicitly supports another mechanism.

1. Check whether your workload fits

Check your chosen model’s minimum cacheable length, cache lifetime, and pricing before implementation. These vary by provider and model. A repeated 300-token instruction may be too short to qualify, while a reusable 15,000-token document is a stronger candidate.

2. Put stable content before changing content

Build requests in this order: stable instructions, stable tool definitions or reference material, then the current user task. Follow the API’s required message structure, but keep reusable content as an identical leading prefix.

Do not insert a fresh timestamp, random identifier, or request-specific metadata near the beginning. Changes can break prefix matching and reduce reuse. Preserve tool ordering, document formatting, and message order between otherwise comparable requests.

For example, send your unchanged repository conventions before “Review this diff,” rather than inserting the diff ahead of those conventions. Keep essential instructions intact; caching is useful precisely because you do not have to shorten them.

3. Enable caching for the actual model and route

On supported Claude APIs, explicit caching uses a cache_control field on an eligible content block, with type set to ephemeral. Place the cache breakpoint at the end of the stable content you want reused. Anthropic commonly supports a five-minute lifetime and, on eligible configurations, a longer one-hour option with different pricing.

Supported OpenAI models generally apply prompt caching automatically once eligibility requirements are met. Do not copy Claude-specific cache fields into an OpenAI request and expect equivalent behavior.

With 59API, use https://api.59api.com as the relay host and confirm the documented endpoint path, model identifier, and cache-field support for your API format. SDK compatibility does not by itself guarantee identical cache behavior or billing across routes.

4. Prove that reads are happening

Run two requests close together with the same long prefix and different final questions. The first may populate the cache; the second should report cached input if the request qualifies.

If reads remain zero, check prefix differences, minimum length, expiry, model changes, and whether the route supports caching. A faster response alone is not proof of a discounted cache read.

5. Calculate savings before optimizing further

Suppose each request contains 10,000 stable tokens plus 1,000 new tokens. If cache reads hypothetically cost 10% of ordinary input, a full hit costs the equivalent of 2,000 ordinary input tokens instead of 11,000: roughly 82% lower input cost. This excludes output charges and any initial cache-write premium.

Compare total cost across realistic repetitions, including misses and expiry. Claude cache writes can cost more than ordinary input, so a cache created once and never reused may increase spending.

Keep the base price low, too

59API combines low-cost, pay-as-you-go access to native Claude and GPT models without downgrading, with compatibility for Claude Code, Codex, and OpenAI SDKs. That makes it a practical option for developers optimizing both token rates and repeated-context costs. It also offers a referral rebate.

Sign up for 59API when you are ready to benchmark a small representative workload, then keep caching only where usage counters and billing show real savings.

Tarifs · Docs

Prêt à commencer ?

Connectez Claude et GPT en quelques minutes aux prix les plus bas, sans bridage. Inscrivez-vous pour votre clé API.

Inscription gratuite