Prompt caching for role-play: cut long-chat costs in RisuAI and SillyTavern
Why long role-play chats get expensive, how prompt caching bills the repeated part at a fraction of the input price, and how to turn on Claude's prompt caching in RisuAI and SillyTavern.
Prompt caching bills the part of a request that repeats, such as the character card, the system prompt and the older chat history, at a fraction of the normal input price, and a role-play chat repeats almost its whole prompt on every message. On Claude, cached input costs a tenth of the input price or less, so a long chat's input bill can drop to roughly a fifth; RisuAI and SillyTavern both support it without plugins or extensions.
Last updated: 15 November 2026. Ratios below are from the Claude list prices in the catalogue on that date.
Why long chats get expensive
A model remembers nothing between messages, so the app resends everything it needs every time: system prompt, character card, persona, lorebook entries, memory summaries and recent history. The cost of one message is:
input tokens × input price + output tokens × output price
Take a chat that sends 20,000 tokens per message. A hundred replies is 2,000,000 input tokens. At 500 tokens a reply, output is only 50,000 tokens, so even at several times the input price, output is the smaller part of the bill.
What caching changes
Most of those 20,000 tokens are identical from one message to the next: only the newest messages at the end are new. With caching, the model reuses its work on the identical beginning and bills it at the cached input price.
Claude's prices, relative to its normal input price:
| Tokens | Price |
|---|---|
| Read from the cache | 0.1× or less |
| Written to the cache, kept 5 minutes | 1.25× |
| Written to the cache, kept 1 hour | 2× |
If 18,000 of the 20,000 tokens come from the cache at 0.1×, one message's input costs 2,000 + 18,000 × 0.1 = 3,800 tokens' worth, about a fifth of the uncached 20,000. The message that writes the cache costs a little more than usual, which is why caching pays off over a long chat rather than on one message.
| Model | Input / 1M | Cached / 1M | Output / 1M | Context |
|---|---|---|---|---|
| Claude Sonnet 5.5 | $2 | $0.1 | $10 | 1M |
| Claude Opus 5.5 | $4 | $0.2 | $20 | 1M |
| Claude Sonnet 4.6 | $3 | $0.3 | $15 | 1M |
| Claude Haiku 5.5 | $0.1 | $0.01 | $0.5 | 1M |
| DeepSeek V4.1 Flash | $0.15 | $0.003 | $0.6 | 1M |
The cached column is what a cache read costs per 1M tokens. Many other models, including the DeepSeek, Gemini, GPT and Kimi families, cache automatically when a request starts with the same tokens as a recent one, so they need no setup at all; see prompt caching.
RisuAI: cache points on a custom model
RisuAI's plain Custom API sends the OpenAI format, and switching its Format to Anthropic Claude sends every message as plain text, which drops the cache markers. Use a custom model instead:
- Settings, Advanced Settings, Custom Models, then +.
- URL
https://api.inferray.com/v1/messages, Format Anthropic, Tokenizer Claude, Request Model a Claude id such asclaude-sonnet-5-5, Key/Password your key, and thehasFirstSystemPromptandhasStreamingflags. - Pick the model from the Custom Models group in the model list.
- Mark the cache: a Cache Point item in the prompt template, or Enable Experimental Features and then Automatic Cache Point, which marks the last three user messages.
- Optional: Claude 1 Hour Caching in Advanced Settings, for chats with long pauses between messages.
The RisuAI guide has every field. No provider plugin is needed; RisuAI plugins explained covers when one still helps.
SillyTavern: the Claude source and config.yaml
SillyTavern adds cache markers only on its Claude source:
- In API Connections, set Chat Completion Source to Claude.
- Open the source's custom URL settings and enter
https://api.inferray.com/v1as the server URL and your key as the password. The SillyTavern guide names each field. - Choose a model in Claude Model, such as
claude-sonnet-5orclaude-opus-4-8. - In
config.yaml, underclaude:, setcachingAtDepth: 0. AddenableSystemPromptCache: trueto cache the system prompt too, andextendedTTL: truefor one-hour entries. Restart SillyTavern.
Getting more cache hits
- Keep the beginning stable. The cache matches from the first token onwards: a random macro, a timestamp, or a lorebook entry that changes every turn near the top stops everything after it from matching.
- Put what changes last. Stable instructions and the character card first, the newest messages at the end. If you reorder the prompt template, keep anything that changes every turn below the cached part.
- Mind the clock. A five-minute entry expires if you pause longer than that between messages. If you often do, the one-hour option costs more to write but keeps hitting.
- Rerolls are cheap with caching. A reroll sends the same prompt again, so it reads almost all of it from the cache.
- Very short prompts are not cached. Below a model-specific minimum, about 1,024 tokens for most Claude models, nothing is cached; the request still works.
Checking that it works
Send two messages a minute apart, then open your request logs in the console. The second request should show most of its input as cached tokens. If it shows none, something near the start of the prompt changed between the two messages.
FAQ
Does prompt caching change the replies?
No. The model processes the same prompt; caching only changes how the repeated part is computed and billed.
Do I need a plugin or extension for caching?
No. RisuAI does it with a custom model and cache points, SillyTavern with its Claude source and config.yaml.
Is caching worth it for short chats?
Less so. The first message writes the cache at a higher price, and the savings come from the messages after it. In a chat of a few short messages, the difference is small either way.
Which models cache automatically?
Many non-Claude models, including the DeepSeek, Gemini, GPT and Kimi families, cache matching prefixes on their own. Claude caches only what the request marks, which is what the settings above do.
Prices on this page come from the model catalog and were current on November 27, 2026.
On a Token Plan, each request comes off your allowance at the model's list price, with cached input at the cached price, so caching makes the same allowance last longer.