Skip to content

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.

Owl mascot

What you'll learn

  • Claude prefers XML tags for structure and has a dedicated system parameter, 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 familyStrengthsPrompting styleWatch out for
Claude (Anthropic)XML structure, tool use, long contextUse <tags> for structure, system param for instructionsSlower on very long prompts, rate limits tighter by default
Gemini (Google)Massive context (1M+), fast inferenceUse markdown headers, explicit "Output:" prefixTool calling format differs from OpenAI/Anthropic
GPT-4 (OpenAI)Broad ecosystem, structured output modeUse markdown, "role: system" as first messageOverconfident on ambiguous prompts
Llama/Mistral (open)Local deployment, no rate limitsBe explicit, avoid implicit assumptions, use few-shot heavilySmaller 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

MistakeHow you notice itThe fix
Claude prompt with no system parameterInstructions mixed with conversation lose priorityAlways pass system instructions via the system parameter, not inline
Gemini ignores formattingOutput doesn't match requested formatUse explicit "Output:" prefix and markdown headers. Gemini's parser is different from Anthropic's
Open model ignores instructionsModel produces generic output ignoring your formatAdd few-shot examples. Open models rely more heavily on pattern matching from examples
Provider-specific feature used cross-providerresponse_format or tool_choice doesn't work on another providerAbstract 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

Next: Day 5, Safety & Production