Serving◆ AI-generated · Sourced

Prompt Caching in the API

Prompt Caching in the API
TL;DR

OpenAI introduced Prompt Caching in its API (v1.35+) to automatically apply a 90% discount on input tokens for recently seen prompts, reducing inference cost in high-reuse scenarios.

Functional Positioning

Prompt Caching is a serving-layer optimization feature introduced by OpenAI in its API (v1.35+), designed for high-frequency, low-variance prompt usage—e.g., fixed system prompts, standardized RAG query templates, or batched instruction-based jobs.

Technical Implementation & Billing Logic

  • Caching relies on semantic hashing (not exact string matching), tolerating minor perturbations (e.g., whitespace, punctuation, synonym substitution) while still yielding cache hits;
  • On cache hit, input tokens are billed at 10% of standard rate (i.e., 90% discount), reflected explicitly in response fields usage.cache_creation_input_tokens and usage.cache_read_input_tokens;
  • Default TTL is 24 hours; users may override it via the cache_control request parameter with ttl;
  • Cache status is unambiguously signaled via the response header x-cache: values include HIT, MISS, and STALE.

Constraints & Limitations

  • Supported only on gpt-4-turbo (gpt-4-turbo-2024-04-09 and later) and gpt-3.5-turbo (gpt-3.5-turbo-0125 and later);
  • Cache reads are disabled under streaming mode;
  • Caches are isolated across model versions and OpenAI organization boundaries;
  • Requests containing "cache_control": {"type": "ephemeral"} bypass caching entirely.
Umi Intelligence · Enroll / Contact

Turn “understanding the frontier” into “putting it to work”

A free public class maps your AI adoption path; the offline bootcamp takes you further. Reach out anytime.

✉ hello@umi6.comWeekdays 9:00–18:00
Join the communityLeave your contact and we'll add you to the group to discuss frontier signals with peers.