Please enable JavaScript.
Coggle requires JavaScript to display documents.
Building with the Claude API - Coggle Diagram
Building with the Claude API
Claude model familiy
Sonnet
Inteliggent modal that balances quality speed and cost
Cost medium
Best used for:
Document creation and edition
Commin coding tasks
Image analysis
Content marketing and copywriting
Opus
Highest level of intelligence
Cost: Hight
Best used for:
Long running tasks (more focus)
Strategic planning with multistep problem
Advanced software development (large-scale architecting)
Task that could benefit from advanced reasoning
Haiku
Most cost-efficient and latency-optimized model
Cost low
Best used for:
Language translation
Quick code completions and suggestions
Most high volumen, straighforward process task
Claude processing
Embedding
Each token gets converted into an embedding - a long list of numbers that represents all possible meanings of that word
Think of embeddings as numerical definitions that capture semantic relationships
Contextualization
Claude refines each embedding based on surrounding words to determine the most likely meaning in context
This process adjusts the numerical representations to highlight the appropriate definition.
Tokenization
breaks your input text into smaller chunks called tokens
These can be whole words, parts of words, spaces, or symbols. For simplicity, think of each word as one token.
Generation
The contextualized embeddings pass through an output layer that calculates probabilities for each possible next word.
Output layer
Probablitiy of next possible word
EOS
End of sequence token
Model indicates when to stop
API Response
Structured response
Usage
Count of input and output tokens
Stop reason
Why generation ended
Message
Generated text
Multi-trun conversations
Claude doesn't store any of your conversation history
Each request is completely independent
To have a conversation
Manually maintain a list of message
in your code
Provide the list of message
with following up requests
How it works?
Take Claude's response and add it to
your message list as an assistant message
Add your follow-up question as another user message
Send your initial user message to Claude
Send the entire conversation history to Claude
System prompts
Customize how claude responds to a user input
Tome, style, etc
How system prompts work?
Provide guideance on how to repond
define them as plain strings and pass them into the create function call
Temperature
parameter that controls how predictable or creative Claude's responses will be
Value from 0 to 1
Influences selection probablitities
Levels
Medium temperature (0.4 - 0.7)
Summarization
Education content
Problem solving
Low temperature (0.0 - 0.3)
Data extraxtion
Content modetration
Coding assistence
High temperature (0.8 - 1)
Brainstorming
Creative writing
Joke generation
Response streaming
lets users see text appear chunk by chunk as Claude generates it
Events
ContentBlockStart
Start of a new block containing text, tool use, or other content
ContentBlockDelta
Chunks of the actual generated text
MessageStart
A new message is being sent
ContentBlockStop
The current content block has been completed
MessageDelta
The current message is complete
MessageStop
End of information about the current message
Structured data
Claude by default try to add comments, header or footer
Prefill
Where the text starts
Stop sequences
Where the next needs to stop