AI / Claude Models Basics Interview Questions
What is the temperature parameter in Claude and how does it affect responses?
The temperature parameter controls the randomness of Claude's output. Higher temperatures produce more varied, creative responses; lower temperatures produce more focused, deterministic responses.
| Value | Behaviour | Best for |
|---|---|---|
| 0 | Deterministic — same input almost always gives same output | Factual Q&A, data extraction, classification |
| 0.1–0.5 | Low randomness — mostly consistent with slight variation | Code generation, technical analysis, structured output |
| 0.7 (default) | Balanced — the API default | General conversation, most tasks |
| 1.0 | High randomness — diverse, creative outputs | Creative writing, brainstorming |
| 1.0 (max for most tasks) | Maximum randomness | Highly experimental creative tasks |
# Setting temperature in an API call response = client.messages.create( model="claude-opus-4-8", max_tokens=1024, temperature=0, # deterministic â best for factual tasks messages=[{"role": "user", "content": "What is the capital of France?"}] ) # For creative writing creative_response = client.messages.create( model="claude-opus-4-8", max_tokens=2048, temperature=1.0, # more creative variation messages=[{"role": "user", "content": "Write a poem about the ocean."}] )
Temperature range: 0 to 1 for standard tasks. Values above 1 are available but not recommended for most use cases as they can produce incoherent output. When using extended thinking, Anthropic recommends keeping temperature at 1 (the default for thinking-enabled requests).
More Related questions...