HuggingFaceEndpoint denies the token

I have validated the token with the
huggingface_hub.login(“xxx”) (this works: Login successful)
strong textrepoid=“meta-llama/Meta-Llama-3.1-8B”
*HuggingFaceEndpoint (repo_id=repoid, token=“xxx”)
I get the error
Could not authenticate with huggingface_hub. Please check your API token. (type=value_error)

I have tried multiple times with new tokens.

hi @Kapi3
It seems you use langchain. I don’t know whether this might help or not:

If not please share your script and library version.

  • I faced the same problem while running a langchain based project with langgraph cli command “langgraph dev”
  • After debugging I got an error raised at “langchain_huggingface/llms/huggingface_endpoint.py(211)” with some explanations and recommendations
  • the root problem was : “Blocking call to socket.socket.connect Heads up! LangGraph dev identified a synchronous blocking call in your code. When running in an ASGI web server, blocking calls can degrade performance for everyone since they tie up the event loop.”
  • Following the recommendation for dev environment I ran the following command : “langgraph dev --allow-blocking”
  • This solved the problem in dev
  • For production, the recommendation is to set env variable BG_JOB_ISOLATED_LOOPS=true
1 Like