Chain-of-Thought Prompting
Chain-of-thought prompting asks a model to work through a problem step by step before giving the final answer. For multi-step maths, logic and planning tasks, writing out intermediate steps often improves accuracy.
Without and With Step-by-Step Reasoning
A shop sells pens at 3 for $2. Ayesha buys 12 pens and pays with a $10 note.
How much change does she get?
Think through it step by step, then give the final answer on a line starting "Answer:".Sample response: 12 pens is 4 groups of 3 pens. Each group costs $2, so 4 x $2 = $8. Change from $10 is $10 - $8 = $2. Answer: $2
Asking for a separate "Answer:" line makes the result easy to extract in code while still letting the model reason.
Structured Reasoning Fields
When you need JSON, put a reasoning field before the answer field so the model reasons first:
Decide whether the refund request is eligible under the policy
(refunds within 30 days, item unused).
Return JSON: {"reasoning": "...", "eligible": true|false}
Request: Bought 12 days ago, opened but never used.Sample response:
{"reasoning": "Purchased 12 days ago, which is within 30 days. Opened but unused meets the 'item unused' condition.", "eligible": true}Reasoning Models
At the time of writing (2026) many models have a built-in "thinking" or reasoning mode that reasons internally before replying. With these models you usually do not need to say "think step by step"; instead give a clear goal and constraints, and control the reasoning effort through the API setting if one is offered.
When to Use It
- Good for: arithmetic, multi-step logic, comparing options, planning, debugging.
- Not needed for: simple lookups, classification, rewriting, translation.
- Costs: more output tokens and slower responses.
- Shown reasoning can still contain mistakes; verify important answers.
Frequently asked questions
Does "let's think step by step" still work?
It still helps many non-reasoning models on multi-step problems. Reasoning models already do this internally.
Should I show chain-of-thought to users?
Usually show only the final answer, and optionally a short explanation. Raw reasoning can be long and confusing.
Is the model's reasoning always faithful?
Not necessarily. Written steps may not exactly reflect how the model reached its answer, so test outputs rather than trusting the explanation.