# Does OpenAI have a top\_k parameter?

**URL:** <https://community.openai.com/t/does-openai-have-a-top-k-parameter/612410>\
**Category:** API\
**Created:** [February 3, 2024, 8:12am UTC](https://community.openai.com/t/does-openai-have-a-top-k-parameter/612410 "2024-02-03T08:12:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin.erca.2017](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/martin.erca.2017/32/299418_2.png) [@martin.erca.2017](https://community.openai.com/u/martin.erca.2017)\
**Post date:** [February 3, 2024, 8:12am UTC](https://community.openai.com/t/does-openai-have-a-top-k-parameter/612410/1 "2024-02-03T08:12:39Z")

</div>

Hello,

Does OpenAI have a top\_k parameter?

If yes, what is the default value and range of top\_k?

Thank you.

---

<div class="post-metadata">

**Author:** ![dignity\_for\_all](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dignity_for_all/32/300058_2.png) [@dignity\_for\_all](https://community.openai.com/u/dignity_for_all)\
**Post date:** [February 3, 2024, 8:38am UTC](https://community.openai.com/t/does-openai-have-a-top-k-parameter/612410/2 "2024-02-03T08:38:27Z")

</div>

As far as I understand, there seems to be no language model currently provided by OpenAI that allows you to specify the top\_k hyperparameter.

Top-K sampling considers the top k tokens, but you can use the Top-p (nucleus) sampling value as a hyperparameter.

In language models, top\_p and top\_k are not mutually exclusive concepts, but it seems that only top\_p is available as a hyperparameter through the API at the moment.

It seems that some past language models provided top\_k sampling as well.Please take this into consideration too.

> [@Top K? How can I set it?](https://community.openai.com/t/top-k-how-can-i-set-it/3712):
>
> I understand that the API allows us to specify for Top P, but how about Top K? Is there a default Top K that is already implemented? Or can we change Top K by deriving it from Top P?

---

<div class="post-metadata">

**Author:** ![tocsa](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tocsa/32/448449_2.png) [@tocsa](https://community.openai.com/u/tocsa)\
**Post date:** [November 27, 2024, 9:35pm UTC](https://community.openai.com/t/does-openai-have-a-top-k-parameter/612410/3 "2024-11-27T21:35:34Z")

</div>

Do we know the reason for this? Is it possible that `top_k` will be introduced on the API? When someone wants to decrease chaos, - besides setting `temperature` to `0` - it’s somewhat easier to set the `top_k` to `1` than guessing a `top_p`. Everywhere else `top_k` is a standard knob, why would the OpenAI API leave it out if `temperature` and `top_p` is already available? I’m kind of shocked.
