# estimate_rewarm_cost

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/cold_cache/estimate_rewarm_cost)

Estimate cold input spend and the incremental cost over a cache hit.

Prices are derived by running two synthetic usage payloads through the
ordinary `estimate_cost` path -- one billed as a full cache read, one as a
cold request -- so the catalog stays the single source of truth. Outputs
are zeroed on both sides so the delta is input-only.

A `provider/model` prefix is resolved through `_effective_model_name`, the
same helper `resolve_prompt_cache_policy` uses, so a spec that resolved a
policy is priced under the name that policy was chosen for. Letting the two
disagree is what makes a warning silently never fire.

## Signature

```python
estimate_rewarm_cost(
    context_tokens: int,
    model_spec: str,
    policy: PromptCachePolicy,
) -> RewarmEstimate | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `context_tokens` | `int` | Yes | Prefix size to price. |
| `model_spec` | `str` | Yes | `provider:model` identifier for the invocation. |
| `policy` | `PromptCachePolicy` | Yes | Resolved policy, which selects the cache-write price bucket. |

## Returns

`RewarmEstimate | None`

Price estimate, or `None` when the prefix is below the provider's cache
minimum or the usage cannot be priced defensibly.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/cold_cache.py#L1051)