SSkilvy

Three message roles

  • system — rules and the assistant's role for the whole dialogue ("you are a polite support assistant").
  • user — the user's messages.
  • assistant — the model's past replies (passed for context).
const res = await fetch(URL, {
  method: 'POST',
  headers: { Authorization: 'Bearer ' + key, 'Content-Type':'application/json' },
  body: JSON.stringify({
    model: 'some-model',
    max_tokens: 300,
    system: 'You are a concise technical assistant.',
    messages: [{ role:'user', content:'Explain what a cache is' }]
  })
});
const data = await res.json();

Key parameters

  • temperature — "creativity": 0 is strict and predictable, ~1 is varied. Use low for facts.
  • max_tokens — the cap on answer length (and cost).
  • stop — stop sequences where to cut generation.
  • stream — receive the answer in chunks for a "typing" UI.

Exercise

Make two identical requests with temperature 0 and 1. Compare the stability of answers. Feel when each is needed.

The system prompt sets the rules of the game. Parameters tune behavior. Master them for a predictable product.

🧠 What temperature for factual answers?