Stepthrough Start free

What is top-p in AI?

Quick answer

Top-p, also called nucleus sampling, is a setting that controls how adventurous a model's word choices are. At each step the model only picks from the most likely next words whose chances add up to the top-p value, such as 0.9. A lower value keeps wording safe and predictable; a higher value allows more variety.

Last updated

Take the free module →Module 7 of the free Intro to AI Automation course, about 12 minutes. No account needed.

Updated · By Robert Breen

Why it matters for a small business

Top-p and temperature both change how random an answer is, in different ways. Temperature reshapes all the odds; top-p cuts off the unlikely tail. OpenAI's API documentation generally recommends changing one or the other, not both.

For business automations that classify, extract or fill a template, predictable is what you want, so the defaults or a lower setting work well. For brainstorming social ideas, more variety can help. Either way, neither setting adds facts, so a creative setting doesn't make an answer more correct.

If you see top-k in a tool's settings, it is a related control that keeps a fixed number of likely words. Most office automations never need to touch any of these.

In a real lesson: n8n AI Agent Tutorial: Save Social Media Ideas to Google Sheets

In the n8n AI Agent Tutorial, you add an OpenAI Chat Model under the agent's Chat Model input, connect your API key and pick gpt-5-mini from the Model dropdown. The lesson leaves the model's options at their defaults, which is the right start.

If the social media ideas came out too samey, that node's options are where you would add Top P or Sampling Temperature and nudge one of them up a little. If the agent wrote the wrong columns to Google Sheets, those settings wouldn't fix it: the system message and tool description would.

n8n AI Agent node with a system message written for BrightPath Marketing
n8n AI Agent node with a system message written for BrightPath Marketing

Try this lesson free or read the step-by-step guide.

Common confusions

Top-p vs temperature

Temperature makes every word choice more or less random. Top-p removes the least likely words from the choice altogether. Adjust one at a time.

Top-p vs top-k

Top-k keeps a fixed number of likely words, like the top 40. Top-p keeps however many it takes to reach a share of the probability.

Tips

  • Leave top-p at the default unless you have a reason to change it.
  • Change top-p or temperature, not both, and test five runs after each change.
  • Some reasoning models ignore or don't offer these settings.

More AI basics terms

Where you use it: free lessons

Frequently asked questions

What is a good top-p value?
Most people leave the default. If you change it, small steps such as 0.8 to 0.95 are common; test with your real task.
Does top-p affect accuracy?
Not directly. It changes how varied the wording is. Accuracy comes from good facts and instructions.
Should I change top-p or temperature?
Usually temperature, and only one of them. Most users leave both at the defaults.

All AI glossary terms, A to Z · Free prompt templates