Lesson 1 of 4

LLM API Use & Prompt Engineering

Prototyping a feature that summarizes support tickets starts with the same handful of concepts, whichever model or provider ends up underneath.

Prompt engineering techniques

Four techniques cover most of what moves a prompt from 'roughly works' to reliable.

Few-shot examples

Show the model two or three examples of the exact input→output shape you want, instead of describing it abstractly.

Step-by-step reasoning

Asking the model to reason through steps — or breaking a task into stages yourself — improves accuracy on harder tasks.

System prompt scoping

The system message sets persistent behavior and constraints, separate from the user's actual request — the first place to fix a misbehaving assistant.

Structured output

Constraining the model to emit valid JSON against a schema, so downstream code can parse the response without fragile string parsing.

Common failure modes

None of these are edge cases — expect to see all four regularly.

Hallucination

The model states something false with full confidence — no error, no signal, just wrong.

Prompt injection

Untrusted input — a webpage, a document, a user message — contains instructions the model follows as if they came from you.

Context window overflow

Once conversation history exceeds the context limit, older content gets silently truncated or the request fails, depending on the client.

Non-determinism

Even at low temperature, the same prompt can produce a different response run to run — design around this rather than assuming exact repeatability.

Exercises

Look at the sanitized request/response below, then work through both exercises.

POST /v1/chat/completions
{
  "model": "claude-...",
  "system": "Classify the ticket. Respond with JSON only: {\"category\": string, \"severity\": string}",
  "messages": [
    { "role": "user", "content": "Customer says invoices are duplicating after every retry." }
  ]
}

Response:
{
  "category": "billing",
  "severity": "high"
}

Concept check

Answer in your head first, then click a question to reveal the answer.

Scenario checklist

Work through the sample request/response and check each item off. Progress is saved in your browser.

Go deeper

These primers are a starting point. Read the primary sources to build real fluency.

Training Notes

What building this project taught me.

This module is the foundation, not the gap

LLM API fluency wasn't itself a named gap in the job-hunting scan, but Agentic Engineering in Production (the next lesson) assumes this vocabulary — tool calls, system prompts, structured output all show up there again.

The example API shape is illustrative

Exact request/response fields vary by provider (Anthropic, OpenAI, etc.) — the pattern (system message, user message, structured response) is what to carry between them, not this exact JSON.