Unauthorized 401

Hello,
Can someone help with:

Error in generating tool call with model:
401 Client Error: Unauthorized for url: https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions
(Request ID: pM7Zmc)

401 Unauthorized
[Step 0: Duration 0.54 seconds]

1 Like

That’s strange. You don’t need a token to use that model, so authentication errors don’t normally occur.:thinking:
Perhaps you’re passing the wrong token when you don’t need to…

I am facing the same issue in smol agents first agent template

1 Like

from HF Discord:


posti

I solved by creating a secret with the api token in the space settings

posti

On the space settings, go to Variables and secrets, and create a new secret named HF_TOKEN
The value of the secret should be your access token
If you need to create an access token, go to your HF profile page
On the left menu, go to the access token option
Andre’s then the Create new token, on the top right

11 Likes

Thanks it worked, I always got that error when creating a new space

1 Like