Introduction to Claude Models
Nikhil Rangarajan
Data Scientist
$$
# Vague prompt prompt = "Write a product description"
# Specific prompt prompt = """Write a 150-word product description for a wireless bluetooth speaker targeting college students. Use an energetic, casual tone and highlight portability, battery life, and sound quality."""
$$
# Vague prompt
prompt = "Write some code"
# Specific prompt
prompt = """Write a Python function
that validates email addresses
using regex.
Include error handling for invalid
inputs and return both boolean result
and descriptive error message."""
# Conservative generation response1 = client.messages.create( model="claude-sonnet-4-20250514", temperature=0.2, messages=[{"role": "user", "content": prompt}])
# Creative generation response2 = client.messages.create( temperature=0.8, messages=[{"role": "user", "content": prompt}])
print("Temperature 0.2 Response (Conservative)") print(response1.content[0].text)
print("Temperature 0.8 Response (Creative)") print(response2.content[0].text)
Temperature 0.2 Response (Conservative)
A rainbow is an optical phenomenon that occurs when sunlight and rain are present
simultaneously. It forms when white light from the sun passes through water
droplets in the atmosphere, causing the light to refract, reflect, and disperse
into its component colors...
Temperature 0.8 Response (Creative)
Ah, rainbows! Those magical bridges painted across stormy skies that never fail
to make us pause and wonder. Picture this: millions of tiny water droplets hanging
in the air after a rainfall, each one acting like a miniature crystal ball. When
sunlight hits these droplets, something absolutely enchanting happens...
$$
$$
client.messages.create(
model="claude-sonnet-4-20250514",
temperature=0.7,
top_p=0.3, #Likely words
messages=[{"role":"user",
"content":prompt}])
$$
Introduction to Claude Models