Wrap a text payload into a content-block list with an Anthropic ephemeral cache_control marker. LiteLLM passes the marker through to Anthropic (and OpenRouter → Anthropic). For other providers the marker is stripped at the request egress (see :func:`_strip_cache_control`, applied in
(text: str)
| 261 | |
| 262 | |
| 263 | def _cached_text(text: str) -> list[dict]: |
| 264 | """Wrap a text payload into a content-block list with an Anthropic |
| 265 | ephemeral cache_control marker. |
| 266 | |
| 267 | LiteLLM passes the marker through to Anthropic (and OpenRouter → |
| 268 | Anthropic). For other providers the marker is stripped at the request |
| 269 | egress (see :func:`_strip_cache_control`, applied in :func:`_llm_call`), |
| 270 | because not every provider merely *ignores* it — Gemini in particular |
| 271 | turns it into a 400. The list-of-blocks payload that remains is a valid |
| 272 | OpenAI-compatible content shape. |
| 273 | """ |
| 274 | return [{"type": "text", "text": text, "cache_control": {"type": "ephemeral"}}] |
| 275 | |
| 276 | |
| 277 | def _accepts_cache_control(model: str) -> bool: |
no outgoing calls