I'm having an error message working with my User access tokens

i’m working on chatpdf and i got this error while working on HuggingFaceHub_api_keys.

llm = HuggingFaceHub(repo_id=‘OpenAssistant/oasst-sft-1-pythia-12b’)
chain = RetrievalQA.from_chain_type(llm=llm, chain_type=“stuff”, retriever=knowledge_base.as_retriever())
response = chain.run(question)

st.success(“Completed question.”)
st.write("Answer: ", response)

File “C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\llms\huggingface_hub.py”, line 112, in _call
raise ValueError(f"Error raised by inference API: {response[‘error’]}")

ValueError: Error raised by inference API: Authorization header is correct, but the token seems invalid

1 Like

I just got the same error message. Did you ever resolve this?

i created the env. and placed the token in it…
then i called it this way: os.environ[“HUGGINGFACEHUB_API_TOKEN”] = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”