The short answer

#

Almost always prompting. Prompting changes what the model does with what it knows; RAG changes what it knows at request time; fine-tuning changes how it behaves by default, and is the only one of the three that costs a training run and ties you to one model version. Work down the list in that order. Prompt first. Add retrieval when answers need information the model does not have. Consider fine-tuning only when a long, cached system prompt with good examples still cannot get the style, format or latency you need, and your provider actually offers it, which for most frontier models it does not.


_10
const response = await client.messages.create({
_10
model: 'claude-sonnet-5-5',
_10
max_tokens: 1024,
_10
system: [
_10
{ type: 'text', text: instructionsAndExamples, cache_control: { type: 'ephemeral' } },
_10
],
_10
messages: [{ role: 'user', content: userInput }],
_10
});

What it means

#

Prompting is everything you put in the request: the system prompt, instructions, worked examples, and constraints such as a JSON schema for the output. It is free to change, takes effect on the next request, and leaves you free to switch models. Its limit is knowledge: the model only knows what it learned in training plus what fits in the prompt, though with a 1M-token window "what fits" is a great deal.

RAG (retrieval-augmented generation) adds knowledge at request time. You search your own documents for the passages relevant to the question and put them in the prompt. The knowledge stays current, can differ per user, and can be cited. It does not change how the model writes or reasons, only what it has in front of it.

Fine-tuning continues training the model on your examples so that its default behaviour shifts: a particular tone, a strict output format, domain vocabulary, shorter answers. It is poor at teaching facts. Knowledge in weights is fuzzy, cannot be updated without another training run, and cannot be cited, so a model fine-tuned on your docs will still make things up about them. Fine-tuning needs hundreds to thousands of graded examples, an evaluation to prove it helped, and a repeat for every model release. Most frontier models, Claude among them at the time of writing, are not available for customer fine-tuning at all; check your provider's docs.

Many wishes that sound like fine-tuning ("I want it to always answer like our support team", "it should always output our ticket format") are met by a few thousand tokens of instructions and examples in a cached system prompt. Cached reads cost about a tenth of normal input, so a 3,000-token prompt on Haiku costs a few hundredths of a cent per request.

How to choose

#

Start with instructions and examples

Write the behaviour down plainly, then show two or three examples of good output. Put all of it in the system prompt and mark it for caching so the cost is paid once.


_10
const instructionsAndExamples = `
_10
You write release notes for a developer tool. British English, no marketing language.
_10
Format: one H2 per area, bullet points, each bullet starts with a verb.
_10
_10
Example input: "fixed the bug where exports failed on empty tables"
_10
Example output:
_10
## Exports
_10
- Fix exports failing when a table has no rows
_10
`.trim();

If the model ignores an instruction, it usually contradicts another one, sits in the middle of a wall of text, or describes the outcome without saying what to do instead. Fix the prompt before reaching for anything heavier.

Lock the format with structured outputs

If the problem is shape rather than content, do not fine-tune for it and do not beg in the prompt. Give the API a schema and it constrains the response to match.


_17
import { z } from 'zod';
_17
import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod';
_17
_17
const Ticket = z.object({
_17
category: z.enum(['billing', 'bug', 'feature']),
_17
priority: z.enum(['low', 'medium', 'high']),
_17
summary: z.string(),
_17
});
_17
_17
const response = await client.messages.parse({
_17
model: 'claude-sonnet-5-5',
_17
max_tokens: 1024,
_17
system: 'Classify the support email.',
_17
messages: [{ role: 'user', content: email }],
_17
output_config: { format: zodOutputFormat(Ticket) },
_17
});
_17
console.log(response.parsed_output); // typed as z.infer<typeof Ticket>

Add RAG when the model needs your knowledge

If the model says it does not know, or confidently gets your facts wrong, no amount of prompting will fix that: the information is not there. Either put the documents in the (cached) prompt if they fit, or build retrieval if they do not, change often, or differ per user. Retrieval also gives you citations, which fine-tuning never can.

Consider fine-tuning for style at scale or latency

The remaining cases are narrow. You run millions of requests and a smaller fine-tuned model would be materially cheaper than a cached prompt on a hosted one. You need a very particular voice or format that a prompt holds only most of the time, and you have thousands of graded examples to train on. Or you need the lowest possible latency from a small model and the prompt is a large share of the work. Even then, do the maths against prompt caching first, and remember you will redo the fine-tune when the base model is retired.

A decision list

  1. Can you describe the behaviour in words? Write it in the system prompt. Add two or three examples. Cache it.
  2. Does the output need a fixed shape? Use structured outputs with a schema.
  3. Does the model lack facts, or get yours wrong? Put the documents in the prompt if they fit, otherwise build RAG.
  4. Do the facts change often or differ per user? RAG, with per-user filtering in the database.
  5. After all of that, is a specific style or format still unreliable, do you have thousands of graded examples, and does your provider offer fine-tuning for the model you need? Then, and only then, fine-tune.
  6. Otherwise, improve your evaluation set, then your prompt, then your retrieval, in that order.

Common pitfalls

#
  • Fine-tuning to add knowledge. It does not work the way people hope. The model will still hallucinate, you cannot update it, and you cannot cite it. Use RAG or a long cached prompt.
  • Changing the prompt without an evaluation. Keep twenty to fifty real inputs with expected outputs and run them on every change. Otherwise you are tuning by anecdote.
  • Breaking the cache. A timestamp, request ID or user name at the top of the system prompt invalidates the cache on every call. Put stable instructions first and anything that varies in the user message.
  • Building RAG for a corpus that fits. Count tokens first. A few hundred pages go in a cached prompt with no pipeline to maintain.
  • Locking into a fine-tuned model version. When the base model is deprecated, your fine-tune goes with it. Prompts and retrieval move to the next model in an afternoon.
#

quick question

Was this resource helpful?