Appearance
Model-Specific Prompting
Claude, Gemini, GPT-4, and open models process prompts differently. What works on one model can fail silently on another. This lesson covers the specific quirks, strengths, and prompting strategies for each major model family, plus how to write prompts that degrade gracefully across providers.

What you'll learn
- Claude prefers XML tags for structure and has a dedicated
systemparameter, use it, don't inline system prompts - Gemini handles massive context (1M+ tokens) but needs explicit formatting for tool calls and structured output
- GPT-4 responds well to markdown formatting and benefits from "let's think step by step" more than Claude does
- Open models (Llama, Mistral) need more explicit instruction and fewer implicit assumptions
The problem
You write a prompt that works perfectly on Claude. You switch to Gemini and the model ignores your formatting and produces a wall of text. You try GPT-4 and it hallucinates function parameters. Model-specific prompting isn't about picking favorites, it's about understanding each model's parser so your prompts work reliably everywhere.
Options & when to use each
| Model family | Strengths | Prompting style | Watch out for |
|---|---|---|---|
| Claude (Anthropic) | XML structure, tool use, long context | Use <tags> for structure, system param for instructions | Slower on very long prompts, rate limits tighter by default |
| Gemini (Google) | Massive context (1M+), fast inference | Use markdown headers, explicit "Output:" prefix | Tool calling format differs from OpenAI/Anthropic |
| GPT-4 (OpenAI) | Broad ecosystem, structured output mode | Use markdown, "role: system" as first message | Overconfident on ambiguous prompts |
| Llama/Mistral (open) | Local deployment, no rate limits | Be explicit, avoid implicit assumptions, use few-shot heavily | Smaller context windows, less consistent formatting |
Build it
Claude-specific: XML tags and system parameter
Claude performs best when instructions are clearly separated using XML tags. Always provide primary directives through the system parameter rather than inline.
python
# Claude responds well to XML-structured prompts
prompt = """<task>Analyze the following code for bugs</task>
<code>
{code}
</code>
<format>
For each bug found, return:
<finding>
<severity>HIGH|MEDIUM|LOW</severity>
<line>line number</line>
<description>what's wrong</description>
<fix>suggested fix</fix>
</finding>
</format>"""Gemini-specific: explicit output formatting
Gemini responds well to explicit markdown headers and clear output prefixes. Its parsing mechanism differs from Claude, so structured block identifiers are critical.
python
# Gemini responds well to markdown and explicit output instructions
prompt = """## Task
Analyze the following code for bugs.
## Code
{code}
## Output Format
Return your analysis in the following format EXACTLY:
BUGS FOUND:
1. [severity] Line [N]: [description]
Fix: [suggested fix]
If no bugs found, output: NO BUGS FOUND"""Provider-agnostic pattern
To support multiple models, use a universal format based on clear markdown sections. This approach abstracts provider-specific quirks into a single robust template.
python
def build_universal_prompt(task, context, output_format):
return f"""# Task
{task}
# Context
{context}
# Output Format
Return your response in the following format:
{output_format}
# Important
- Follow the output format exactly
- If you can't complete the task, explain why
- Do not add commentary outside the specified format"""Open model adaptations
Open-weight models typically require more explicit guidance. Provide extensive few-shot examples to reinforce the desired formatting and behavior.
python
# Open models need more explicit instruction
# Add few-shot examples, avoid relying on implicit understanding
prompt = """Task: Classify the sentiment of product reviews.
Examples:
Review: "This product is amazing, I love it!"
Sentiment: POSITIVE
Review: "Broke after two days. Waste of money."
Sentiment: NEGATIVE
Review: "It works but the setup was confusing."
Sentiment: NEUTRAL
Now classify this review:
Review: "{review}"
Sentiment:"""What goes wrong
| Mistake | How you notice it | The fix |
|---|---|---|
| Claude prompt with no system parameter | Instructions mixed with conversation lose priority | Always pass system instructions via the system parameter, not inline |
| Gemini ignores formatting | Output doesn't match requested format | Use explicit "Output:" prefix and markdown headers. Gemini's parser is different from Anthropic's |
| Open model ignores instructions | Model produces generic output ignoring your format | Add few-shot examples. Open models rely more heavily on pattern matching from examples |
| Provider-specific feature used cross-provider | response_format or tool_choice doesn't work on another provider | Abstract provider-specific features behind a compatibility layer |
Confirm it worked
Execute this simple test across providers to verify format consistency. Both responses should successfully follow the numbered list constraint despite differing model architectures.
python
# Test the same prompt on two providers
prompt = "List three colors. Return as: 1. COLOR_NAME"
claude_result = call_claude(prompt)
gemini_result = call_gemini(prompt)
# Both should return numbered lists
assert "\n1." in claude_result
assert "\n1." in gemini_result