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?
- For simple tasks like translations, summarizing a paragraph, or basic sentiment analysis.
- When latency (speed) is crucial and you want to consume as few tokens as possible.
- In combination with highly intelligent models that need very little explanation.
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.
When to use?
- When the output must strictly adhere to a specific tone of voice or data structure.
- If zero-shot fails to capture the subtleties of your domain.
- When you want to address specific edge cases in advance.
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?
- For mathematical problems, code architecture issues, or complex logical reasoning.
- When you need to navigate a decision tree.
- For complex benchmarks where you prioritize accuracy over speed and token costs.
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
- Start with Zero-shot: Always test your prompt zero-shot first. Modern models often surprise you. Why waste tokens if you don't have to?
- Scale up to Few-shot for parsing errors: Do you often get errors in your web application because the API does not return valid JSON? Add 2 to 3 concrete examples.
- Activate CoT for hallucinations: If the output structure is correct but the internal logic fails, add the instruction to write out the thinking process first. (You can hide this process in the backend and only show the final conclusion to your user).
- Monitor your usage: Especially if you run an advanced setup, CoT generation tokens add up quickly. Use it selectively.