Error 401 Client Error: Unauthorized for url

When using model card of my private speech recognition model with LM, I got this error:

401 Client Error: Unauthorized for url: https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main

while the same model without lm works fine.

Is there anything wrong on my model or model card or …
Any help is appreciated.

Hi @talids, you’re getting a 401 error because you’re not authenticated when making the request, and either:

  • the model doesn’t exist
  • the model is private

From your message, I get that you’re in the second situation. Please make sure that you’re authenticated when calling the API. You’ll need a personal access token to do so, which you can then pass in the Authorization header of your request in the form Bearer <TOKEN>.

Thanks @pierric,
Actually, my model is private, but I logged in already, and access token is also correct. I checked them many times, even I generated new access tokens, but the error message is the same.

Hi @talids,

When you say that you’re “logged in already”, what do you mean exactly? Do you mean that you’re logged-in in your browser on hf.co?

What do you use to make your call to https://huggingface.co/api/models/taliai/tali-asr-with-lm/revision/main? Do you use a python lib?

I see that you also emailed support, let’s keep the discussion here if possible @talids, as it could be useful for others.

Sure!
Here is a bit more detail.
This is the error we are getting
And this is the case for this specific model.
our other ASR model which is not withLM is working fine.

Thanks for those additional details, the team is going to investigate more and we’ll come back to you.

1 Like

Awesome. Plz let me know if we can provide anymore info to help pinpoint the issue faster.

The problem seems to be resolved. Did you guys did something on your end?

@talids we didn’t change anything directly related, AFAIK. Can you confirm that it’s still working for you?

Having this @talids @pierric any idea what the solution or the problem is.

1 Like

@israel can you give more details?

  • is it happening when you’re trying to use the inference widget? if not, what specific HTTP call are you making?
  • what model/repo are you talking about?
1 Like

@ pierric, same issue here.

The Model/repo in question: yhavinga/t5-base-dutch
The error message: “Repository Not Found for url: https://huggingface.co/api/repos/create.
Please make sure you specified the correct repo_id and repo_type.
If the repo is private, make sure you are authenticated.
Unauthorized - Unauthorized”

I am logged in, it seems to make no difference if I do so with a read or write access token.

1 Like

@tsei902 completely same issue here.

I found that my authentication key was not being used, that solved it.

Hi everyone

I’m getting the same issue when trying to run the textural inversion example from the example script here: Textual Inversion

Edit: the error specifically is “HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/main/tokenizer/vocab.json” followed by a hefty traceback

This happens with CompVis/stable-diffusion-v1-4 model and I’m “logged in” using huggingface-cli, so that whoami returns “OzzyD”.

Edit: Incidentally, I can open this file from the link in my browser, so it must be something to do with authenticating on the command line.

I’m having the feeling I’m not doing this correctly. Am I?

Hi @OzzyD , have you accepted the license on CompVis/stable-diffusion-v1-4 · Hugging Face page ? If yes, can you share which version of huggingface_hub you are using and the full traceback you are getting ?

We are making efforts to make error messages more explicit but gated repos are still not handled perfectly. Next version of huggingface_hub (to be released soon) should solve that.

Hi @Wauplin. I have accepted the license on the v1-4 model page.

However, whilst checking for what version of huggingface_hub I had installed, I decided to update my Python environment to the one suggested in the requirements.txt file for that repo, which I already thought it was. This appeared to fix my issue. My rookie mistake.

I look forward to the update to huggingface_hub and thank you for your time :slightly_smiling_face:

1 Like