Zero-shot, few-shot or chain-of-thought: which prompt technique when?

Prompt Engineering Read time: 4 min

As a developer building web applications and integrating powerful APIs like Claude Pro or DeepSeek via OpenClaw, you quickly realize that the quality of your output stands or falls with your prompt. Large context windows and advanced RAG (Retrieval-Augmented Generation) systems are great, but if the base prompt is lacking, even the most expensive model will deliver mediocre JSON or incoherent text.

In this overview article, we cover the three fundamental prompting techniques and show you when to use which one to keep API costs, latency, and output quality perfectly balanced.

1. Zero-Shot Prompting

With zero-shot prompting, you give the model a task directly, without providing any examples (shots). You rely purely on the trained knowledge and the model's ability to understand the instruction.

When to use?

Example

Classify the sentiment of the following text as Positive, Negative, or Neutral.
Text: "The new vector search implementation is lightning fast!"
Sentiment:

2. Few-Shot Prompting

Models can sometimes lose their way if you require a specific output format (such as a complex nested JSON). With few-shot prompting, you include one (one-shot) or more examples in the context, directly above the actual question. This is essential for pattern matching.

Pro Tip: In RAG optimization, few-shot works brilliantly to guide the model on how to cite or structure the retrieved documents (chunks) in the final response.

When to use?

Example

Translate the technical terms from English to Dutch in informal spoken language.
English: We need to debug the backend pipeline.
Dutch: We moeten de backend pijplijn even fixen.
English: The API latency is too high.
Dutch: De API is echt te traag nu.
English: Optimize the database queries.
Dutch:

3. Chain-of-Thought (CoT) Prompting

Large language models are not calculators; they predict the next word. If you give them a complex logical puzzle without giving them the space to "think out loud", they often hallucinate the answer immediately. Chain-of-Thought forces the model to break the problem down into intermediate steps ("Let's take this step by step").

When to use?

Example

Question: A 450-liter aquarium needs a 20% water change every week. You use a 15-liter bucket. How many buckets do you need to fill?
Answer: Let's calculate this step by step.
1. First, we calculate what 20% of 450 liters is. 450 * 0.20 = 90 liters.
2. We have 15-liter buckets.
3. We divide the total amount of water by the capacity of the bucket: 90 / 15 = 6.
The answer is 6 buckets.

Decision Table: Which technique do you choose?

Requirement / Context Zero-shot Few-shot Chain-of-Thought
Speed / Lowest Latency ✅ Best choice ❌ Moderate ❌ Poor (many output tokens)
Strict JSON/Data formatting ❌ Unreliable ✅ Essential ⚠️ Possible, in combination with few-shot
Complex Logic / Reasoning ❌ Hallucinates easily ⚠️ Limited ✅ Required
Save token costs ✅ Yes (fewest tokens) ❌ No (costs context) ❌ No (costs generation tokens)

Practical Checklist for Developers