> Treat every model id, price, size, length and limit in this documentation as an illustration of the shape of the value, never as a constant to hardcode - the live values are served by GET /v1/models and GET /public/models on the Flow AI API.

# Prompt Caching

> Pay less for a prompt the model has seen recently.

Many requests start the same way: the same system prompt, the same tools, the same long document. Models that support caching keep that start for a few minutes and charge much less to read it again. A cache read often costs a tenth of the input price or less.

## How to get cache hits

* **Put what stays the same first.** System prompt, tools and documents go at the start; the user's new message goes last. The cache only matches a prompt from its first token.
* **Send it again soon.** Caches last minutes, not hours.
* **Make it long enough.** Hosts only cache prompts past a minimum length, often around 1,000 tokens.

Flow AI sends a repeated prompt to the same host where it can, so the cache you built is the one you hit.

## Automatic or marked

Some labs cache for you; others need you to mark where the cached part ends.

| Labs                                                 | How                                                   |
| ---------------------------------------------------- | ----------------------------------------------------- |
| OpenAI, DeepSeek, xAI, Google (Gemini 2.5 and later) | Automatic. Nothing to change.                         |
| Anthropic                                            | Add `cache_control` to the last part you want cached. |

**`Python`**

```python title="Python"
response = client.chat.completions.create(
    model="<anthropic model id>",
    messages=[
        {
            "role": "system",
            "content": [{
                "type": "text",
                "text": LONG_INSTRUCTIONS,
                "cache_control": {"type": "ephemeral"},
            }],
        },
        {"role": "user", "content": "Summarise section 3."},
    ],
)
```

## Seeing it

`usage.prompt_tokens_details.cached_tokens` shows how many input tokens were read from the cache. The [Logs](https://ai.hyperflow.fun/console/logs) page shows cached tokens and the cache price for each request.

## Billing

Cached input is charged at the model's cache read price. Models that charge to write a cache list a cache write price too; you pay it on the request that fills the cache. Both are on the model's page. See [Pricing](/models/pricing).