AI

Chain of Thought Prompting, With Examples

Chain of thought prompting asks an AI to reason step by step before answering. How it works, zero-shot and few-shot examples, and when to skip it.

By OmniAI Editorial · Nov 20, 2026 · 14 min read

Chain of thought prompting is a technique where you ask an AI model to work through a problem step by step before giving its final answer. Instead of jumping straight to a result, the model writes out its intermediate reasoning, which makes it more accurate on maths, logic and multi-step questions, and lets you see where it went wrong. The simplest version is adding a line like "Think step by step before you answer" to your prompt.

This guide explains how chain of thought prompting works, with chain of thought prompting examples you can copy: zero-shot, few-shot and structured versions. It also covers how it compares with few-shot prompting, prompt chaining, ReAct and tree of thoughts, and when to skip it, especially with today's reasoning models.

What Is Chain of Thought Prompting?

A "chain of thought" is the series of intermediate reasoning steps that lead to an answer. Chain of thought (CoT) prompting gets a language model to produce those steps in its output.

The idea was popularised by a 2022 Google paper, "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models" by Jason Wei and colleagues. They showed that if your example answers include worked reasoning, large models copy that pattern and get much better at arithmetic, common-sense and symbolic reasoning problems. The benefit only appeared in large models; small models produced reasoning that looked plausible but didn't help.

Later the same year, a paper titled "Large Language Models are Zero-Shot Reasoners" by Takeshi Kojima and colleagues found you don't even need examples. Simply adding "Let's think step by step" raised one model's accuracy on the MultiArith maths benchmark from 17.7% to 78.7%.

Why Chain of Thought Prompting Works

An LLM generates text one token at a time, and each token can only use the computation that happened before it. When a model answers a multi-step question in one word, it has to do all the reasoning "in its head" in a single step. When it writes out intermediate steps, each step becomes part of the context the model reads for the next one. In effect, the written reasoning gives the model more room to compute.

That's why chain of thought helps most on tasks with several dependent steps (calculations, logic puzzles, planning, multi-condition rules) and helps little on simple lookups or creative writing. For a refresher on how models predict tokens, see our prompt engineering guide.

Chain of Thought Prompting Examples

Here are chain of thought prompting examples, from simplest to most controlled. The task: "A café sells coffee for $4 and muffins for $3. On Monday it sold 40 coffees and some muffins, earning $205 in total. How many muffins did it sell?"

Standard prompt (no chain of thought)

A café sells coffee for $4 and muffins for $3. On Monday it sold
40 coffees and some muffins, earning $205 in total. How many muffins
did it sell? Answer with just the number.

Forcing a bare number is where weaker models make arithmetic slips, because they can't show any working.

Zero-shot chain of thought

A café sells coffee for $4 and muffins for $3. On Monday it sold
40 coffees and some muffins, earning $205 in total. How many muffins
did it sell? Think step by step, then give the final answer on its
own line.

A typical response: "Coffee revenue: 40 × $4 = $160. Muffin revenue: $205 − $160 = $45. Muffins: $45 ÷ $3 = 15. Final answer: 15."

Few-shot chain of thought

Show one or two solved examples that include the reasoning, then ask the real question:

Q: A shop sells pens for $2 and notebooks for $5. It sold 10 pens and
some notebooks for $45. How many notebooks?
A: Pens earned 10 × $2 = $20. Notebooks earned $45 − $20 = $25.
Notebooks sold = $25 ÷ $5 = 5. The answer is 5.

Q: A café sells coffee for $4 and muffins for $3. On Monday it sold
40 coffees and some muffins, earning $205 in total. How many muffins?
A:

The model copies the format: reasoning first, then "The answer is…". Few-shot chain of thought is useful when you want a specific reasoning style, such as always checking units or listing assumptions.

Structured chain of thought

In apps, you usually want the reasoning separated from the answer so you can show only the answer to users or parse it reliably:

Work out the answer to the question below.
Write your reasoning inside <thinking> tags, then put only the final
answer inside <answer> tags.

Your code then reads the text between the <answer> tags. You can log the reasoning for debugging without showing it to users.

Two rows split by a dotted divider: the top row has a grey square with one long ink arrow straight to a small grey circle; the bottom row has the same square with four short ink arrows passing through three small grey squares to an orange circle.
A standard prompt jumps to the answer; chain of thought prompting reaches it through visible intermediate steps.

A business example

Chain of thought isn't only for maths. For a decision, ask the model to lay out the factors before concluding:

We sell a $29/month plan. A competitor launched at $19/month with
fewer features. Should we cut our price?
First list the facts we know and the facts we're missing. Then
weigh the options (keep, cut, add a cheaper tier) one by one,
with pros and cons. Then give a recommendation and what data
would change it.

This tends to produce a more balanced answer than "Should we cut our price?" alone, and it shows you which assumptions the recommendation rests on.

More Chain of Thought Prompting Examples

Chain of thought works across many kinds of tasks, not just arithmetic.

Debugging code

This function should return the average order value per customer,
but the numbers look too high. Before suggesting a fix, walk through
what the code does line by line with a small example input, note
where the result goes wrong, and only then propose the change.

Asking for a trace with a small example makes the model check its assumptions instead of guessing at a fix.

Classifying a support ticket

Classify this ticket as Billing, Bug, Feature request or Account.
First list the key facts in the ticket in one or two short lines,
then explain which category fits best and why the others don't.
End with: Category: <name>

Short reasoning before a label helps with tickets that mention several topics, and the final line keeps the output easy to parse.

Checking a policy rule

Our refund policy: refunds within 30 days for annual plans, no
refunds for monthly plans, except for duplicate charges.
A customer on a monthly plan was charged twice on 3 March and asks
for a refund on 20 March. Check each condition of the policy in
order, then say whether a refund is allowed.

Rules with exceptions are where models most often skip a condition; asking it to check each one in order reduces that.

Chain of Thought Prompt Templates You Can Reuse

Copy and adapt these:

  • Basic: "Think step by step. Then give the final answer on the last line, starting with 'Answer:'."
  • Facts first: "First list the relevant facts from the text. Then reason from those facts only. Then answer."
  • Plan then do: "First write a short plan of the steps you'll take. Then carry out each step. Then give the result."
  • Check your work: "Solve the problem, then check your answer a different way. If the two disagree, find the error before answering."
  • Options and decision: "List the options, give the main pros and cons of each, then recommend one and say what would change your mind."
  • Hidden reasoning: "Reason inside <thinking> tags. Put only the final answer for the user inside <answer> tags."

How to Tell Whether Chain of Thought Helps

Don't assume; measure. Take 20 to 50 real examples with known correct answers, run them with and without chain of thought, and compare:

  • Accuracy: how many answers are correct.
  • Cost: average input and output tokens per request.
  • Latency: how long users wait.

If accuracy barely moves, drop chain of thought and save the tokens. If it improves a lot, keep it, and consider a cheaper model with chain of thought instead of a larger model without it.

Chain of Thought Variants

Researchers have built many techniques on the same idea:

  • Self-consistency: run the same chain of thought prompt several times, then take the most common final answer. Different reasoning paths that agree are more likely to be right. It costs more tokens but improves reliability on maths and logic.
  • Least-to-most prompting: ask the model first to break a problem into simpler subproblems, then solve them in order, each using the previous answers.
  • Auto-CoT: generate chain of thought examples automatically instead of writing them by hand.
  • Tree of thoughts: let the model explore several reasoning branches, evaluate them and backtrack from dead ends, like a search. In its 2023 paper, on the Game of 24 puzzle, GPT-4 with standard chain of thought solved 4% of problems while tree of thoughts solved 74%. It needs many model calls and custom code, so it suits hard puzzles more than everyday prompts.

Chain of Thought vs Few Shot Prompting

Chain of thought vs few shot prompting is a common mix-up, because they combine:

  • Few-shot prompting gives the model a few examples of inputs and outputs so it learns the format and style you want.
  • Chain of thought asks for reasoning steps before the answer.
  • Few-shot chain of thought does both: the examples include the reasoning, not just the answers.

Use plain few-shot for formatting and classification tasks; add chain of thought when the task needs several steps of reasoning.

Chain of Thought vs Prompt Chaining

Chain of thought vs prompt chaining is about where the steps happen:

  • Chain of thought happens inside one response: the model reasons through all the steps in a single generation.
  • Prompt chaining splits a task across several separate model calls: for example, one call extracts facts from a document, a second analyses them, a third writes the summary. Your code passes each output into the next prompt.

Prompt chaining gives you more control: you can check, fix or use different models at each step. Chain of thought is simpler and cheaper for a single reasoning task. Many apps use both, with chain of thought inside the harder steps of a chain.

Chain of Thought vs ReAct

Chain of thought vs ReAct matters for agents. ReAct, short for "reasoning and acting", interleaves reasoning with actions: the model thinks about what to do, calls a tool (search, a calculator, an API), reads the result, then reasons again. Plain chain of thought only reasons over what is already in the prompt, so it can't look up facts it doesn't know and may confidently reason from wrong ones. ReAct is the pattern behind most AI agents today; chain of thought is its "thinking" half.

Split by a dotted divider: on the left three grey rounded boxes stacked vertically and joined by ink arrows; on the right a grey thought bubble and an orange wrench joined in a loop by two curved ink arrows.
Chain of thought reasons in one pass; ReAct loops between reasoning and tool actions.

Chain of Thought vs Tree of Thought

Chain of thought vs tree of thought comes down to one path versus many. Chain of thought prompting asks for a single line of reasoning in one response, and it works with any model through a plain prompt. Tree of thought turns reasoning into a search: the system generates several candidate next steps, asks the model to rate them, keeps the promising ones and backtracks from dead ends. It solves puzzles that need exploration far better, but it needs custom code and many model calls per question. For everyday prompting, chain of thought (or a reasoning model) is the practical choice; tree of thought belongs in research and in specialised planning or puzzle-solving systems.

Chain of Thought in Production Apps

Using chain of thought inside a real product raises a few practical questions:

  • Hide or show the reasoning? Most apps show only the final answer and keep the reasoning for logs, because long reasoning slows down and confuses users. Some tools, such as tutors or analysis assistants, show it on purpose.
  • Parse reliably. Ask for the answer in a fixed format (tags, a final "Answer:" line or structured JSON output) so your code never has to guess where the answer starts.
  • Control cost. Reasoning tokens are output tokens, which usually cost more than input tokens. Cap the length ("keep your reasoning under 150 words") or use chain of thought only for the requests that need it.
  • Stream carefully. If you stream responses to users, don't stream the hidden reasoning; buffer until the answer section starts.
  • Log for debugging. When an answer is wrong, the stored reasoning often shows exactly which step failed, which tells you whether to fix the prompt, the retrieved data or the model choice.

Chain of Thought and Reasoning Models

Modern reasoning models do chain of thought on their own: they are trained to think through a problem internally before answering, and many APIs let you set how much thinking effort to spend. That changes the advice:

  • Don't add "think step by step" by reflex. OpenAI's guidance for its reasoning models says such prompts are unnecessary because the models already reason internally, and can sometimes hurt.
  • Give goals, not scripts. With reasoning models, high-level instructions ("check edge cases, prefer the simplest correct solution") usually work better than dictating every step.
  • Use the effort or thinking setting instead of prompt tricks when you need deeper reasoning.
  • Still use chain of thought with fast, non-reasoning models, small local models, or when you need the reasoning in a specific visible format.

When Not to Use Chain of Thought Prompting

Chain of thought has costs:

  • More tokens and latency: reasoning text can be several times longer than the answer, so it costs more and takes longer.
  • No gain on simple tasks: lookups, translations, rewriting and classification rarely improve.
  • Reasoning can be unfaithful: the written steps may not reflect how the model actually reached its answer. Anthropic's research has found that reasoning models often don't mention hints that influenced their answers. Treat the chain as an explanation to check, not proof.
  • Small models may ramble: they can produce long, confident reasoning that is wrong.

Tips for Better Chain of Thought Prompts

  1. Ask for the answer in a fixed place (last line or <answer> tags) so it's easy to find and parse.
  2. Match examples to your domain: a few-shot example about invoices works better for invoice questions than a maths puzzle.
  3. Ask the model to check its work for calculations: "verify the result before the final answer".
  4. Keep reasoning out of user-facing output when it would confuse or slow users down. You can set this up in your system prompt.
  5. Measure it: compare accuracy with and without chain of thought on 20 to 50 real examples before making it the default.

FAQ

What is chain of thought prompting in AI?

It is a prompting technique that gets a language model to write out its intermediate reasoning steps before the final answer. This improves accuracy on multi-step problems such as maths, logic and planning, and makes mistakes easier to spot.

What is an example of chain of thought prompting?

Adding "Think step by step, then give the final answer on its own line" to a maths word problem is the simplest example. A few-shot version includes one or two solved examples that show the reasoning before the answer.

Is chain of thought prompting still useful?

Yes, for non-reasoning and smaller models, and when you need reasoning in a particular format. With reasoning models that already think internally, explicit "think step by step" prompts are usually unnecessary; adjust their effort setting instead.

What is the difference between chain of thought and tree of thoughts?

Chain of thought follows one line of reasoning in a single response. Tree of thoughts explores several possible reasoning paths, evaluates them and backtracks, using many model calls. It can solve harder puzzles but costs much more.

Does chain of thought prompting reduce hallucinations?

It can reduce reasoning and arithmetic errors, but not made-up facts. A model can reason carefully from a false premise. For factual accuracy, give it sources through retrieval or tools, as ReAct-style agents do.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog