# TypeError: InferenceClient.text\_generation() got an unexpected keyword argument

**URL:** <https://discuss.huggingface.co/t/typeerror-inferenceclient-text-generation-got-an-unexpected-keyword-argument/160999>\
**Category:** Beginners\
**Created:** [June 28, 2025, 10:28am UTC](https://discuss.huggingface.co/t/typeerror-inferenceclient-text-generation-got-an-unexpected-keyword-argument/160999 "2025-06-28T10:28:36Z")\
**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:** [June 28, 2025, 11:55am UTC](https://discuss.huggingface.co/t/typeerror-inferenceclient-text-generation-got-an-unexpected-keyword-argument/160999/2 "2025-06-28T11:55:31Z")

</div>

Try:

```py
#llm=HuggingFaceEndpoint(repo_id=repo_id,max_length=150,temperature=0.7,token=os.getenv("HF_TOKEN"))
llm=HuggingFaceEndpoint(repo_id=repo_id,max_new_tokens=150,temperature=0.7,token=os.getenv("HF_TOKEN"))

```

> [@TypeError: InferenceClient.text\_generation() got an unexpected keyword argument 'token'](https://discuss.huggingface.co/t/typeerror-inferenceclient-text-generation-got-an-unexpected-keyword-argument-token/158815):
>
> ##########################Code##################################### import os from langchain\_huggingface import HuggingFaceEndpoint from langchain\_core.prompts import PromptTemplate from langchain.chains import RetrievalQA from langchain\_huggingface import HuggingFaceEmbeddings from langchain\_community.vectorstores import FAISS from langchain\_community.document\_loaders import PyPDFLoader, DirectoryLoader Step 1: Setup LLM (Mistral with HuggingFace) HF\_TOKEN=os.environ.get(“HF\_TOKEN”) HU…

---

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