Referencing repeated text once cuts token use without hurting quality
When a prompt sends the same text in multiple examples, writing it once and referencing it elsewhere saves tokens. A small experiment across four LLMs showed no meaningful drop in answer quality. It's a simple cost-saving trick for anyone building with AI.
When you send instructions to an AI model, the text you write is called a prompt. If you include many examples and each one repeats the same background text or rules, the total character count — measured in tokens — grows quickly, raising your API costs. This experiment suggests you can write that shared text once and point the other examples to it instead of copying it every time.
Tests across four different LLMs showed the answers stayed just as good either way. The savings could be even bigger when combined with prompt caching, a feature some providers offer that stores repeated text so it doesn't need to be re-processed. That said, this was a small personal experiment, so it's worth testing on your own use case before assuming the same results.
Key points
- Repeating the same text in multiple examples wastes tokens and raises costs
- Writing shared text once and referencing it kept answer quality intact
- The result held across four different LLMs
- Pairing this approach with prompt caching can multiply the savings
- This was a small experiment — verify it works for your specific use case
Quick term guide
- tokens
- Tokens are small pieces of text that AI systems count when reading or writing.
- AI model
- A program that can understand prompts and produce text, code, or answers.
- AI Mode
- A Google Search feature that uses AI to answer longer, more detailed questions.
- API costs
- Fees paid when software calls an online service programmatically.
- prompt caching
- A technique that avoids re-processing and re-billing identical context that was already sent to the AI recently.
- caching
- Saving an AI's response so you can reuse it later without sending the same request again.
- persona
- A specific personality or role that an AI agent is set to play.
- testing
- The process of checking that software does what it's supposed to do, usually by running it and looking for errors.