Python 88.3%
TypeScript 7.6%
Shell 4.1%
1#!/usr/bin/env python32"""System prompt (text blocks + cache_control) with the Python SDK.34STATUS: LIVE_VERIFIED 2026-09-18 with anthropic 1.7.0 (.venv). Run: .venv/bin/python examples/anthropic/messages/system.py5Key comes from .env (loaded by scripts/live.py); never printed.6"""7import sys8from pathlib import Path910sys.path.insert(0, str(Path(__file__).resolve().parents[3]))11from scripts import live # noqa: E402 (loads .env, gives log_request)12from anthropic import Anthropic # noqa: E4021314client = Anthropic()15MODEL = "claude-haiku-4-5-20251001"16msg = client.messages.create(17 model=MODEL, max_tokens=16,18 system=[{"type": "text", "text": "You are terse. Answer in one word.", "cache_control": {"type": "ephemeral"}}],19 messages=[{"role": "user", "content": "Reply with OK."}],20)21print(msg.content[0].text, "| cache_creation:", msg.usage.cache_creation)22live.log_request("anthropic", "POST", "/v1/messages", 200, 0.00004, "example system.py")23