Interactive guide to LLM API parameters. Understand what temperature, top_p, top_k, frequency penalty, presence penalty, and max tokens actually do, with live examples and provider compatibility.
Controls randomness. Lower values make output more deterministic and focused. Higher values make output more creative and varied.
Example output at moderate temperature
"Kubernetes uses pods as the smallest deployable unit. Each pod runs one or more containers."
Use 0–0.3 for factual/code tasks, 0.7–1.0 for creative writing, 1.5+ for brainstorming.
| Parameter | API Key | Range | Default | Use Case |
|---|---|---|---|---|
| Temperature | temperature | 0–2 | 0.7 | Use 0–0 |
| Top P (Nucleus Sampling) | top_p | 0–1 | 1 | Usually set to 1 |
| Top K | top_k | 1–100 | 40 | Not available in OpenAI API |
| Frequency Penalty | frequency_penalty | -2–2 | 0 | Set to 0 |
| Presence Penalty | presence_penalty | -2–2 | 0 | Use 0 |
| Max Tokens | max_tokens | 1–128000 | 4096 | Set this to control costs |