> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt Caching and Usage

> What the vendors' prompt caches cost and save, how a flow turns one on, and the usage every call records.

A model call can be cheaper when the vendor remembers the start of the request, and every call records what it used.
This page covers both: what a prompt cache is, the `prompt_cache` setting of the
[language model provider](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md), and the usage a call
records.

## What a prompt cache is

A vendor that caches keeps the processed start of a request (instructions, documents, earlier turns) for a few
minutes. A later request that starts with exactly the same content reads it from the cache, at about a tenth of the
input price and faster. The first request writes the cache. Anthropic bills that write at 1.25 times the input price,
and OpenAI does too from GPT-5.6; Gemini's own caching costs nothing extra.

A conversation about a 20,000-token PDF, three turns within five minutes, on an Anthropic model, counting only the PDF:

| Case | Tokens at the input price | How |
| :- | :- | :- |
| Without a cache | 60,000 | 3 × 20,000 |
| With a cache | 29,000 | 25,000 for the first turn (the write, at 1.25×), then 2,000 for each later turn (the read, at 0.1×) |
| One-shot call with a cache | 25,000 instead of 20,000 | The call pays the write and never reads it back |

Content shorter than the vendor's minimum (512 to 4,096 tokens, by model) is never cached and costs the same either
way. Conversations and tool loops, which resend everything every turn, are where a cache pays.

## Each vendor's default

From the vendors' documentation of 2026-11-16:

| Vendor | By default | Turned off by |
| :- | :- | :- |
| Anthropic | Off: caches only what a request marks | Off already |
| OpenAI, GPT-5.6 and later | On: a breakpoint at the end of the latest message | Explicit mode with no breakpoints, which writes nothing |
| OpenAI, earlier models | On | Cannot be; never costs more |
| Gemini, 2.5 and later | On (implicit) | Cannot be; never costs more |

The same vendors, by what a cache write and a read cost:

| Vendor | Write | Read |
| :- | :- | :- |
| Anthropic | 1.25× (5 min), 2× (1 h) | 0.1× |
| OpenAI, GPT-5.6 and later | 1.25× (30 min), 2.5× (12 h) | 0.1× |
| OpenAI, earlier models | No charge | Discounted |
| Gemini, 2.5 and later | No charge | Discounted, not guaranteed |

Gateways pass the underlying vendor's behavior through. An Anthropic model needs marks through OpenRouter and Vercel;
Databricks caches only its own hosted Claude models, and only what is marked. BlobHub places no marks through Vercel,
so an Anthropic model there is not cached.

## `prompt_cache`

`prompt_cache` is a setting of the language model provider, `off` or `on`. A cache write costs more than plain input,
so caching is off unless a flow turns it on: unset means `off`, unlike the other settings, whose unset value leaves
the vendor's default. A run may give it too.

**With `off`, BlobHub adds no cost of its own.**

* Anthropic gets no mark.
* An OpenAI model of GPT-5.6 or later, one the catalog marks `explicit_cache_mode`, is asked for explicit mode with
  no breakpoints, which turns its paid default off.
* An OpenAI model of GPT-5.6 or later that the catalog does not list is sent nothing, and OpenAI's paid default
  applies until the catalog lists it.
* The free automatic caching of Gemini and of earlier OpenAI models stays, since it can only lower the bill.
* Through a gateway no mark is sent. OpenRouter passes the explicit-mode request on to OpenAI and strips it for other
  vendors; the other gateways send nothing, so what a model's paid default does there is the gateway's behavior.

**With `on`:**

| Dialect | What `on` does |
| :- | :- |
| `openai_responses` | Nothing: OpenAI keeps its implicit default |
| `openai_chat` (a gateway) | What the registry entry's `options.cache` says: `top_level` puts `cache_control: {"type": "ephemeral"}` in the body (OpenRouter), `parts` puts it on the last part of the last message (Databricks), `none` sends nothing (`openai_compatible`, Vercel) |
| `anthropic_messages` | One top-level `cache_control: {"type": "ephemeral"}`, which moves forward with the conversation |
| `gemini_generate` | Nothing: Gemini caches on its own |

Where an entry sends nothing, `on` posts the warning `<vendor> places no cache marks; prompt_cache on has no effect`.

**Lifetime.** The vendor's default applies: 5 minutes at Anthropic, 30 at OpenAI. Longer lifetimes go in the
provider's `vendor_settings`, which reach the vendor's request as extra fields.

**A hit needs a stable prefix**, the start of the request exactly as it was the time before. The platform keeps it
stable: see [Chat](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-chat.md).

## Usage

Every call records its usage in one shape, whatever the vendor:

```json theme={null}
{
  "input_tokens": 22450,
  "input_tokens_cached": 20000,
  "input_tokens_cache_write": 0,
  "output_tokens": 310,
  "output_tokens_reasoning": 0,
  "duration_ms": 4120
}
```

| Field | Meaning |
| :- | :- |
| `input_tokens` | All input, cached tokens included |
| `input_tokens_cached` | The part of `input_tokens` read from a cache |
| `input_tokens_cache_write` | The part of `input_tokens` written to a cache |
| `output_tokens` | All output, reasoning included |
| `output_tokens_reasoning` | The part of `output_tokens` spent on reasoning |
| `duration_ms` | The time the vendor call took |
| `by_modality` | Present only where the vendor reports it: `{<modality>: {"input_tokens", "output_tokens"}}` |

Every field is present with `0` where the vendor reports none; `by_modality` is left out instead. A field with a
suffix is a part of its total, never added to it.

**Where it is recorded.** The provider's `component.output` event carries `usage` in its `attributes`, on every call,
whether or not the session logs data. See [Execution Events](https://docs.blobhub.io/blob-types/workflow/workflows/execution-events.md). The
answer carries the same shape in `metadata.usage`, which a thread item keeps.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.