# Only allowed to set max\_tokens to 4095

**URL:** <https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384>\
**Category:** API\
**Created:** [May 17, 2024, 2:13pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384 "2024-05-17T14:13:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kno](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@kno](https://community.openai.com/u/kno)\
**Post date:** [May 17, 2024, 2:13pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384/1 "2024-05-17T14:13:18Z")

</div>

I cannot understand why I can only set max\_tokens to 4095 when the documentations says that gpt-4o and many of the other models have much larger context windows?

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [May 17, 2024, 2:16pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384/2 "2024-05-17T14:16:33Z")

</div>

Welcome to the dev forum.

There’s a difference between input and output. If you’re lucky, you can get 4095 out on applicable models.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![kno](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@kno](https://community.openai.com/u/kno)\
**Post date:** [May 17, 2024, 2:23pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384/3 "2024-05-17T14:23:30Z")

</div>

> [@PaulBellow](#):
>
> There’s a difference between input and output. If you’re lucky, you can get 4095 out on applicable models.

But should´nt I be able to have a context window of 128k tokens. If I do the exact same query inside chatgpt it works, but not with the api. It stops because of max-tokens.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [May 17, 2024, 2:24pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384/4 "2024-05-17T14:24:53Z")

</div>

What model are you using?

Are you getting an error? Just not as much content?

What are you trying to accomplish?

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [May 17, 2024, 6:24pm UTC](https://community.openai.com/t/only-allowed-to-set-max-tokens-to-4095/760384/5 "2024-05-17T18:24:23Z")

</div>

> [@kno](#):
>
> If I do the exact same query inside chatgpt it works

If you do the exact same query in ChatGPT, you are getting `max_tokens` of 1536 or 2048.  
That you are satisfied shows you don’t need to set it so high.

We can guess the output limit was set on new models so that platform costs are reduced, or safety is increased in case the AI goes bonkers and wants to write $4.00 of nonsense output – or because the response simply devolves at that length.

You can simply omit this parameter and get the maximum available after sending your input.
