# TypeError: text\_generation() got an unexpected keyword argument 'token'

**URL:** <https://discuss.huggingface.co/t/typeerror-text-generation-got-an-unexpected-keyword-argument-token/165778>\
**Category:** Spaces\
**Created:** [August 5, 2025, 9:37pm UTC](https://discuss.huggingface.co/t/typeerror-text-generation-got-an-unexpected-keyword-argument-token/165778 "2025-08-05T21:37:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [August 5, 2025, 10:38pm UTC](https://discuss.huggingface.co/t/typeerror-text-generation-got-an-unexpected-keyword-argument-token/165778/2 "2025-08-05T22:38:48Z")

</div>

I recommend updating the `huggingface_hub` library to the latest version and [using `max_new_tokens` instead of `max_length`](https://discuss.huggingface.co/t/typeerror-inferenceclient-text-generation-got-an-unexpected-keyword-argument/160999) and [`huggingfacehub_api_token` instead of `token`](https://python.langchain.com/docs/integrations/llms/huggingface_endpoint/).

```bash
pip install -U huggingface_hub[hf_xet]

```

If you really need to use the old version of the code, I think there is a way to downgrade the `huggingface_hub` library.

```bash
pip install huggingface_hub<0.25

```

---

_[View the full topic](https://discuss.huggingface.co/t/typeerror-text-generation-got-an-unexpected-keyword-argument-token/165778)._
