Prompt Engineering and API Integration · Lesson 2
Basics and Advanced Prompt Engineering Techniques
A prompt is the full input you give a model: instructions, context, examples and the question. Clear prompts state the task, the audience, the format of the output and any constraints. Being specific beats being clever.
Core techniques: zero-shot (just ask), few-shot (show 2–5 worked examples), role or system prompts (set behaviour and persona), and delimiters such as XML tags to separate instructions from data.
Advanced techniques include chain-of-thought (ask the model to reason step by step before answering), self-consistency (sample several answers and take the majority), prompt chaining (split a big task into stages) and asking for structured output like JSON that your code can parse.
Key points
- State task, context, format and constraints explicitly
- Few-shot examples teach format and tone fast
- Chain-of-thought improves multi-step reasoning
- Separate instructions from user data with tags to reduce injection risk
<instructions>
Summarise the support ticket below in 2 bullet points,
then label its priority as LOW, MEDIUM or HIGH.
Reply in JSON: {"summary": [..], "priority": ".."}
</instructions>
<ticket>
{{ticket_text}}
</ticket>