Claude
The market needs capable, safety-focused alternatives to GPT. Claude excels at long-document analysis, nuanced instruction following, code generation, and agentic tool use — with Constitutional AI training for helpful, harmless, honest behavior.
If GPT is a versatile generalist, Claude is the careful, thorough analyst — excels at reading long documents, following complex instructions precisely, and writing clean code with strong reasoning.
Visual Workflows
Start here — study each diagram, then use + / − to zoom if needed.
Scroll inside the frame · use + / − to zoom
Key Takeaways
- 1.Claude by Anthropic is an LLM family known for strong reasoning, long context (200K tokens), safety focus, and excellent coding capabilities — a top choice for complex agentic workflows. Claude family: Haiku (fast, cheap), Sonnet (balanced — best value), Opus (most capable).
- 2.API via Anthropic SDK. Key features: 200K context window, vision (image input), tool use (function calling), prompt caching (cache system prompts and documents), computer use (beta).
- 3.Messages API with system parameter. XML-style thinking in responses.
- 4.Strong at: code review, document analysis, agent orchestration, structured extraction. Pricing competitive with GPT-4o.
Real Example
Scenario
Code review agent: send 50K token codebase as cached context + 'Review for security vulnerabilities'. Claude Sonnet analyzes entire codebase in one pass, returns structured findings with file:line references.
What you would do
In LLM Engineering & APIs, apply Claude to this scenario: Code review agent: send 50K token codebase as cached context + 'Review for security vulnerabilities'. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Open the Code Walkthrough below and run it locally. Change one parameter related to Claude (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Claude happens in the code.
1import anthropic # import dependencies2
3client = anthropic.Anthropic() # key line for Claude4
5message = client.messages.create( # core API call for Claude6 model="claude-sonnet-4-20250514",7 max_tokens=1024,8 system="You are a senior code reviewer. Be thorough and specific.",9 messages=[10 {"role": "user", "content": "Review this function for bugs:\n\ndef divide(a, b):\n return a / b"} # return the result11 ],12)13
14print(message.content[0].text) # show output for debugging15
16# With tool use17tools = [{18 "name": "get_weather",19 "description": "Get weather for a city",20 "input_schema": {21 "type": "object",22 "properties": {"city": {"type": "string"}},23 "required": ["city"],24 },25}]Cheat Sheet
Quick recap
quick ref- •client.messages.create()
- •model: claude-sonnet-4-20250514
- •system= for instructions
- •max_tokens required
- •cache_control for prompt caching
- •tools= for function calling
Common Mistakes
- ✕Not using prompt caching for repeated system prompts — wasting money
- ✕Using Opus for simple tasks — Sonnet is sufficient and cheaper
- ✕Forgetting max_tokens parameter — required by Anthropic API
- ✕Not handling tool_use stop reason in agent loops