When a prompt includes several things (instructions, a document, examples, user input), models can mix them up. Tags make the structure unambiguous. Anthropic recommends this for Claude, and it helps with other models too.
Example
You'll review a contract clause.
<instructions>
- List any obligations for the customer.
- Flag anything unusual compared with a standard SaaS agreement.
- Quote the exact text you're referring to.
</instructions>
<clause>
{clause_text}
</clause>
Put your answer in <obligations> and <flags> tags.Then extract the parts in code:
import re
def tag(text, name):
m = re.search(rf"<{name}>(.*?)</{name}>", text, re.S)
return m.group(1).strip() if m else NoneWhy it helps
- Separation: the model knows exactly where the document ends and your instructions begin.
- Safety: user-provided text inside
<user_input>tags is less likely to be confused with your instructions. - Parsing: asking for output inside tags makes it easy to extract sections.
Tips
- Tag names don't need to be special; use clear ones like
<document>,<example>,<question>. - Refer to tags in your instructions: “Using the text in
<document>…”. - For multiple documents, number them:
<doc id="1">.
Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.