Stack Guide · Anthropic Claude API
Claude and GPT-5 are both capable models, and picking the wrong one for a task costs real money and produces worse results. The models have different strengths. Neither is unconditionally better.
These notes cover where Claude genuinely outperforms GPT-5, where it doesn't, how to pick between Sonnet and Haiku, and how to get the most out of extended context and prompt caching.
Building with the Claude API?
These are the use cases where we route to Claude by default, not because it's always better, but because the difference is meaningful enough that it changes the quality of the output.
Claude's 200k token context window is genuinely useful for specific tasks: analyzing long contracts, processing full codebases, reviewing lengthy research documents without chunking. Most models with large context windows degrade in the middle: Claude maintains reasonable performance across the full window, though not uniformly.
Claude follows multi-part, multi-constraint system prompts more reliably than GPT-5 on complex tasks. When you have a prompt with six or seven specific behavioral requirements, Claude tends to hold them all simultaneously better. GPT-5 sometimes loses track of lower-priority constraints when the prompt is dense.
For applications where users will actively try to make the model step out of its defined role (customer support bots, role-specific assistants, guardrailed research tools) Claude is more resistant to jailbreaks and prompt injection. This matters for deployed products with broad user bases.
For tasks that require writing to sound like a specific voice, maintaining a consistent register, or producing prose that doesn't read as AI-generated, Claude's outputs are often more natural. The difference is noticeable in customer-facing text and long-form content.
Being honest about this is important, routing to the wrong model produces worse outputs at higher cost.
Coding tasks (close — run your own eval)
Coding is close in mid-2026. Claude (Opus 4.8 and Sonnet 5) is our strong default for coding and agentic work, with GPT-5 competitive on many tasks. The gap is small enough that you should run your own eval suite on your actual codebase rather than trusting a blanket benchmark claim in either direction.
Tool use reliability
GPT-5's function calling is more battle-tested. The ecosystem of LangChain, LlamaIndex, and agent frameworks has been tuned against OpenAI's tool call format, and the edge cases are well-understood. Claude's tool use is capable but has more rough edges in agent workflows.
Ecosystem integrations
More third-party tools, libraries, and platforms support the OpenAI API format natively. If you're integrating with an existing product or framework, OpenAI-compatible endpoints are the default. Claude requires explicit integration support.
The 3x cost difference between Sonnet and Haiku means the right choice depends heavily on task complexity and volume.
Claude Sonnet 5
~$3 / 1M input tokens
Complex reasoning, long document analysis, tasks requiring nuanced instruction following, anything where output quality matters more than cost. This is the default choice for difficult tasks where Claude is the right provider.
Claude Haiku 4.5
~$1 / 1M input tokens
High-volume classification, fast responses, simple extraction tasks where Sonnet's quality isn't needed. At 3x lower cost than Sonnet, Haiku is the right choice for straightforward tasks that don't need the full model's capability.
Claude's tool use is capable, with some behavioral differences from OpenAI's function calling worth knowing before you build an agentic system.
The wire format is similar but not identical. Claude returns tool_use blocks in the content array, while OpenAI returns tool_calls as a parallel field. More importantly: Claude tends to be more verbose in its tool call reasoning and more likely to ask for clarification before calling a tool. In agentic workflows this can result in extra round trips. Be explicit in the system prompt that Claude should call tools directly when it has enough information.
Same principles as OpenAI: keep tool sets small (3–7 tools), write clear tool descriptions, handle tool errors explicitly and return them in the tool_result block. Claude benefits particularly from examples in the system prompt, showing it a desired tool call pattern once tends to produce consistent behavior afterward.
The 200k context window is one of Claude's most marketed features. It's genuinely useful in specific situations and wasteful in most others.
When 200k context is genuinely useful
Full contract review without chunking, full codebase analysis in a single call, long legal or research documents where the relationships between sections matter. These are cases where chunking would lose important cross-document context.
When it's wasteful
Sending large contexts for tasks that only need a small portion of the content. If you put a 150k-token document in context to answer a question that only references a specific section, you're paying for 150k tokens of input when 5k would do. Retrieval first, then full-context only when retrieval isn't sufficient.
The 'lost in the middle' problem
LLMs generally perform better on content at the beginning and end of the context window than in the middle. Claude is better than average at this, but the effect is still present. For critical tasks over very long documents, validate that the model is correctly using content from the middle of the document, not just the beginning and end.
Claude's prompt caching lets you mark a prefix of your prompt as cacheable. If a subsequent request shares that prefix, you're charged at a lower rate (90% discount on cache-read tokens, with a small cache-write overhead on the first call).
Useful when: you have a long system prompt that doesn't change between requests (e.g., a 5,000-token system prompt for an assistant that gets called frequently), you're loading a large document into context and querying it multiple times, you're running many similar requests with the same long prefix.
Mark the cacheable content by adding `cache_control: { type: 'ephemeral' }` to the last content block in the prefix you want cached. The cache TTL is 5 minutes. For long-lived system prompts, you'll re-pay the write cost every 5 minutes but save on reads within that window.
Tell us what you're building and what quality bar you're trying to hit. We can help you pick the right model, and test the assumption before you build around it.