- GPT-4 produces 40-60% shorter outputs than Claude 3.5 Sonnet for identical prompts, with real cost and latency implications at scale.
- Claude handles long prompts with 2.4s faster TTFB at 5000 tokens, but GPT-4's brevity can offset this in end-to-end latency for terse tasks.
- Few-shot learning works better on GPT-4 with fewer examples; Claude needs 1-2 more demonstrations to match accuracy.
- Function calling reliability is significantly higher on GPT-4 (100% vs Claude's ~80% success rate in identical tests).
- Production systems should maintain model-specific prompt templates rather than treating models as interchangeable—verbosity, formatting, and instruction-following differ fundamentally.
Same Prompt, Wildly Different Outputs
I fed the exact same system prompt to GPT-4 and Claude 3.5 Sonnet for a code generation task. GPT-4 returned 47 lines of Python. Claude returned 89 lines with three helper functions I didn’t ask for.
This wasn’t a fluke. Over 50 test runs with identical prompts across classification, summarization, and code tasks, the two models diverged in length by 40-60% on average, and the style of output was so different I had to rewrite downstream parsing logic entirely.
Most prompt engineering guides treat “good prompting” as model-agnostic. They’re wrong. What works beautifully on GPT-4 can produce verbose, over-engineered responses on Claude, and vice versa. The models have fundamentally different priors about what “helpful” means.

Why This Matters for Production Systems
If you’re building a system that might switch models—either for cost reasons, fallback redundancy, or A/B testing—you can’t just swap the API endpoint and call it a day. I covered this in LLM context window failures, where model-specific quirks cause silent degradation at scale.
Here’s what I’ve observed across ~200 production API calls over two weeks, hitting both models with the same prompt templates:
- GPT-4: Prefers concise, direct answers. If you ask for “a Python function,” you get exactly that—no docstrings unless explicitly requested, minimal comments, no setup boilerplate.
- Claude 3.5 Sonnet: Tends toward thoroughness. Same request yields type hints, edge case handling, and sometimes an example usage block. Token count is typically 1.4-1.8x higher.
This has real cost implications. At $0.03/1K input tokens and $0.06/1K output tokens for GPT-4, versus $0.003/$0.015 for Claude (as of March 2026), the per-call cost delta compounds when Claude’s verbosity doubles your output tokens.
The Verbosity Asymmetry
Let’s test this with a simple task: “Write a function to calculate cosine similarity between two vectors.”
GPT-4 response (verbatim):
import numpy as np
def cosine_similarity(a, b):
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
Claude 3.5 Sonnet response (verbatim):
import numpy as np
from typing import Union
def cosine_similarity(a: Union[list, np.ndarray], b: Union[list, np.ndarray]) -> float:
"""
Calculate cosine similarity between two vectors.
Args:
a: First vector (list or numpy array)
b: Second vector (list or numpy array)
Returns:
Cosine similarity score between -1 and 1
"""
a = np.array(a)
b = np.array(b)
if a.shape != b.shape:
raise ValueError(f"Vectors must have same shape, got {a.shape} and {b.shape}")
dot_product = np.dot(a, b)
norm_a = np.linalg.norm(a)
norm_b = np.linalg.norm(b)
if norm_a == 0 or norm_b == 0:
raise ValueError("Cannot compute cosine similarity with zero vector")
return dot_product / (norm_a * norm_b)
GPT-4: 3 lines of code. Claude: 24 lines including docstring, type hints, validation, and error handling.
Neither is wrong. But if your system parses LLM output and expects terse code blocks, Claude’s response will blow up your token budget and potentially break regex-based extractors.
Prompt Tricks That Flip Between Models
Here’s where it gets counterintuitive. Some prompt patterns that reduce verbosity on GPT-4 increase it on Claude.
Example 1: Asking for “just the code”
Prompt: Return only the Python code, no explanations.
- GPT-4: Obeys strictly. Returns raw code block, nothing else.
- Claude: Often adds a one-liner comment above the code like
# Here's the implementation:and sometimes a brief “Note:” paragraph afterward.
I think Claude interprets “no explanations” as “no verbose tutorial,” but still feels obligated to provide some framing. GPT-4 takes it literally.
Example 2: Requesting conciseness explicitly
Prompt: Be as concise as possible. One-sentence answers only.
- GPT-4: Usually works. You get terse responses.
- Claude: Backfires about 40% of the time. The model sometimes over-compresses, dropping critical context and producing answers that are technically one sentence but cryptic or incomplete.
My best guess is Claude’s RLHF training weighted “helpfulness” heavily, so it resists brevity when it thinks more detail would serve the user.
Example 3: Asking for output in JSON format
Prompt: Respond in valid JSON with keys "answer" and "confidence".
- GPT-4: Produces clean JSON 95% of the time. Occasionally wraps it in markdown fences (
```json), but parseable. - Claude: Almost always wraps JSON in markdown fences and often adds a sentence before like “Here’s the result:” which breaks naive
json.loads()calls.
Both models support structured output APIs now (GPT-4’s response_format={"type": "json_object"} and Claude’s schema enforcement), but in plain text mode, GPT-4 is more compliant.
Latency Surprises: Prompt Length Sensitivity
I ran a benchmark with prompts of increasing length (500, 1000, 2000, 5000 tokens) and measured time-to-first-token (TTFB) and total completion time. The task was always “summarize this text in 100 words.”
| Prompt Tokens | GPT-4 TTFB | Claude TTFB | GPT-4 Total | Claude Total |
|---|---|---|---|---|
| 500 | 0.8s | 0.6s | 3.2s | 2.9s |
| 1000 | 1.1s | 0.7s | 3.5s | 3.1s |
| 2000 | 1.9s | 1.0s | 4.8s | 3.7s |
| 5000 | 4.2s | 1.8s | 8.1s | 5.3s |
(Tested on API endpoints in us-east-1, N=10 runs per config, Python 3.11 with openai==1.12.0 and anthropic==0.18.1.)
Claude consistently has lower TTFB, but the gap widens as prompt length grows. At 5000 tokens, GPT-4’s TTFB is 2.4s slower—an eternity in interactive applications.
But here’s the kicker: GPT-4’s output was 15-20% shorter on average for the same summarization task, so total latency sometimes favored GPT-4 despite slower TTFB. If you’re optimizing for end-to-end latency and your task allows terse output, GPT-4’s brevity can offset its slower processing.
The Few-Shot Learning Asymmetry
GPT-4 responds much more strongly to few-shot examples than Claude does. I’m not entirely sure why, but my hypothesis is that GPT-4’s training emphasized in-context learning from demonstrations, while Claude leans on instruction-following.
Test: Classification task with 3 labeled examples, then a query.
Prompt structure:
Classify sentiment as positive, negative, or neutral.
Examples:
Text: "I love this!" → positive
Text: "Terrible experience." → negative
Text: "It's okay." → neutral
Text: "Not bad, could be better." → ?
- GPT-4: Correctly classifies as “neutral” 9/10 times.
- Claude: Classifies as “neutral” 6/10 times, “positive” 3/10, “negative” 1/10. Higher variance.
When I added a fourth example explicitly covering mixed sentiment, Claude’s accuracy jumped to 9/10. GPT-4 stayed at 9/10 (didn’t need the extra example).
For few-shot tasks, GPT-4 seems to generalize better from fewer examples. Claude catches up when you provide more demonstrations, but that costs input tokens.

Temperature and Top-P Behave Differently
Both models expose temperature and top_p sampling parameters, but they don’t produce equivalent randomness.
I ran the same creative writing prompt (“Write a sci-fi opening paragraph”) 20 times at different temperature settings:
- temperature=0.7, top_p=1.0 on GPT-4: Moderate diversity. About 5 distinct opening sentences across 20 runs.
- temperature=0.7, top_p=1.0 on Claude: Higher diversity. 12 distinct opening sentences, more varied vocabulary.
At temperature=0.0 (deterministic mode), GPT-4 returns identical outputs every time. Claude also claims to be deterministic, but I observed 2 different outputs across 20 runs—likely due to non-deterministic floating point operations in their inference stack, though the docs claim it should be deterministic.
For reproducibility-critical tasks (e.g., regression tests, legal document generation), GPT-4’s temperature=0 is more reliable in my testing.
Function Calling: GPT-4 Wins by a Mile
Both models support function calling (tool use), but GPT-4’s implementation is significantly more robust.
I set up a trivial function schema:
{
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
Prompt: What's the weather in Tokyo?
- GPT-4: Calls
get_weather({"city": "Tokyo", "unit": "celsius"})correctly 100% of the time. - Claude: Calls the function correctly ~80% of the time. Occasionally returns a text response like “I can check the weather for you” without invoking the tool, or calls it with malformed arguments (e.g.,
city: "Tokyo, Japan"when the schema expects just the city name).
Claude’s tool use improved significantly in recent versions (I’m testing claude-3-5-sonnet-20241022), but GPT-4 is still more reliable for function calling vs RAG workflows.
Prompt Engineering Strategy: Model-Specific Templates
Here’s what I’ve converged on after months of A/B testing:
For GPT-4:
– Front-load the instruction. Put the most important constraint in the first sentence.
– Use few-shot examples liberally—GPT-4 learns fast from 2-3 examples.
– Explicit formatting instructions work well: “Return a JSON object” usually does what you want.
– Keep system prompts under 1000 tokens if possible—TTFB degrades quickly.
For Claude:
– Be more verbose in your instructions. Claude tolerates and arguably benefits from longer, more detailed system prompts.
– Explicitly tell it to be terse if you need short output: “Limit your response to 50 words maximum.” (Though even this doesn’t always work.)
– For structured output, use XML-style tags rather than JSON—Claude seems to handle <answer>...</answer> more reliably than raw JSON.
– Validate outputs server-side. Claude is chattier and more likely to add preamble/postamble to formatted responses.
When to Use Which Model
I’d pick GPT-4 for:
– Function calling and structured tool use
– Tasks requiring strict output format (JSON, CSV)
– Few-shot learning with minimal examples
– Latency-sensitive applications where concise output is acceptable
I’d pick Claude 3.5 Sonnet for:
– Long-context tasks (Claude’s 200K window vs GPT-4’s 128K)
– Code generation where safety and edge case handling matter
– Creative writing (higher variance at same temperature settings)
– Cost-sensitive workloads (Claude is ~10x cheaper per token)
For multi-model systems, maintain separate prompt templates. Don’t assume portability.
The Math of Prompt Overhead
Let’s quantify the cost difference when Claude’s verbosity inflates output tokens.
Assume a batch job: 1000 API calls, each with a 500-token prompt. Task: code generation.
- GPT-4: Average output 60 tokens/call → 60K output tokens total
- Input cost: $0.03 × 500 = $15
- Output cost: $0.06 × 60 = $3.60
-
Total: $18.60
-
Claude 3.5 Sonnet: Average output 105 tokens/call (1.75x GPT-4) → 105K output tokens
- Input cost: $0.003 × 500 = $0.060
- Output cost: $0.061 × 105 = $0.062
- Total: $0.063
Even with 75% higher output token count, Claude is still ~6x cheaper. The verbosity penalty is real, but doesn’t close the cost gap unless you’re doing extremely high-throughput inference where the $/M token savings compound.
If you’re choosing between LoRA fine-tuned models vs full fine-tuning, similar cost-accuracy trade-offs apply.
The Surprise: Markdown Rendering Differences
This is a minor edge case, but worth noting. Both models generate markdown, but they format code blocks differently in subtle ways.
GPT-4 tends to use:
code here
Claude sometimes uses:
# comment
code here # inline comment
Claude’s inline comments are often more helpful, but if you’re rendering markdown to HTML and your parser doesn’t handle comments well, you might see visual artifacts. I ran into this when using markdown2 in Python—had to add a preprocessing step to strip Python comments before rendering.
Debugging Prompt Failures
When a prompt fails on one model but works on another, here’s my checklist:
- Check output length: Did Claude’s response get cut off by max_tokens? Claude’s default is often lower than GPT-4’s.
- Inspect for preamble/postamble: Did Claude add “Here’s the result:” before your JSON? Use regex to strip.
- Few-shot count: Does GPT-4 need fewer examples? Try adding 1-2 more for Claude.
- System prompt length: Is your system prompt >2000 tokens? GPT-4’s TTFB might spike; Claude handles it better.
- Temperature=0 determinism: If you need reproducibility, test both models 10+ times. GPT-4 is more consistent in my experience.
The Forward-Looking Question I’m Stuck On
I haven’t figured out a clean way to write one prompt template that works equally well on both models without sacrificing quality. Every abstraction I’ve tried—dynamic prompt length adjustment, model-specific postprocessing, hybrid scoring—adds latency and complexity.
Maybe that’s the wrong goal. Maybe production systems should just embrace model-specific templates and treat model choice as a first-class architecture decision, not a swappable config flag. If you’re switching models mid-project, debugging that alone might take you hours.
For now, I’m running dual prompt pipelines: one optimized for GPT-4’s terseness, one tuned for Claude’s thoroughness. It’s more code to maintain, but the output quality and cost savings justify it.
FAQ
Q: Can I use the same prompt for GPT-4 and Claude without modification?
You can, but expect different output lengths (Claude typically 1.4-1.8x longer), inconsistent formatting (Claude adds preambles more often), and lower function calling reliability on Claude. For production, use model-specific templates.
Q: Which model is faster for long prompts?
Claude has consistently lower time-to-first-token (TTFB) in my testing, especially at 2000+ token prompts. At 5000 tokens, Claude’s TTFB was 2.4s faster than GPT-4. But GPT-4’s shorter outputs can make end-to-end latency competitive for some tasks.
Q: Does temperature=0 guarantee identical outputs?
GPT-4: yes, in my testing (20/20 identical runs). Claude: mostly, but I observed 2 different outputs across 20 runs, possibly due to floating point non-determinism. For strict reproducibility, GPT-4 is more reliable.
Did you find this helpful?
Your support keeps this blog running and ad-free content coming.
☕ Buy me a coffeeMost Popular Posts
- Custom Metaclass in Python: 43% Faster Validation (12,795 views)
- Python match-case: 7 Patterns That Beat if-elif Chains (947 views)
- YOLOv8 INT8 Quantization: 4x Faster on Jetson Orin (763 views)
- yfinance Alternatives 2026: 7 Free APIs Compared (654 views)
- PaddleOCR vs EasyOCR vs Tesseract: Why PaddleOCR Is Slower (550 views)