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 _callraise ValueError(f"Error raised by inference API: {response[‘error’]}")ValueError: Error raised by inference API: Authorization header is correct, but the token seems invalid
2023-09-24T16:14:40Z
I just got the same error message. Did you ever resolve this?
2023-09-25T01:50:16Z
yesi created the env. and placed the token in it…then i called it this way:  os.environ[“HUGGINGFACEHUB_API_TOKEN”] = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
2023-11-02T01:02:05Z
hey there ! am using huggingface api and encountering same problem , am using react how can i create a .env file for that
2024-01-03T19:32:42Z
Hello, I am following an introductory video from youtube titled:Hugging Face + Langchain in 5 mins | Access 200k+ FREE AI models for your AI appsEverything seems to work well, but I encountered this error message related to the bearer token: {“error”:“Authorization header is correct, but the token seems invalid”}I already tried by creating another token but the error continues.If anybody could find a solution I would be very grateful.
2024-01-18T05:14:28Z
Currently having a similar issue on my end herefrom huggingface_hub import login

login(config['huggingface_api'])

import getpass
from transformers import HfAgent

agent_star = HfAgent(
    "https://api-inference.huggingface.co/models/bigcode/starcoder"
)
text = "this is new building with 14 storeys painted green."
storey_1 = agent_star.run("What is the number of storeys?", text=text)yet i’m getting the following error messageTraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 341, in run
    result = self.generate_one(prompt, stop=["Task:"])
  File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 649, in generate_one
    raise ValueError(f"Error {response.status_code}: {response.json()}")
ValueError: Error 400: {'error': 'Authorization header is correct, but the token seems invalid'}Any advice on this would be greatly appreciated.
2024-01-22T12:19:46Z
I was having the same issue, following a LangChain course and it helped to change os.environ[“HUGGINGFACEHUB_API_TOKEN”] to os.environ[“API_TOKEN”].
2024-01-22T18:24:45Z
I’ll try it out and report back. Thanks for the suggestion.
2024-05-20T01:04:21Z
I too faced the same issue. Changing the permissions of the token to write solved the issue. Please try and confirm.
2024-06-06T16:56:13Z
Changing permission to “write” worked for me.
2024-06-07T06:49:08Z
how can i change the permission to write
2024-06-10T11:00:01Z
Hey did you get how to change the permission?
2024-06-23T02:31:56Z
Hmm I changed mine to write, yet I am still running into the issue.
2024-06-23T03:57:05Z
profile  > settings  >  Access TokensCreate a new Access Token with WRITE permission and use that new token. Changing  the permission on an already existing token doesn’t seem to work. Just create a new token.
2024-06-25T05:17:28Z
hey, that didn’t work for me either. anyone else having the same issue?
2024-07-10T11:34:00Z
If you run the chain.run(“msg”) and shows an error thengo to hugging face account → setting → Access TokenEdit Access Token PermissionsUnder the Repositories check box Write access to contents/settings of all repos under your personal namespace.Under the Inference check box Make calls to the serverless Inference APISave and retry to run your code.