huggingface auth_error ai_generated true

HTTPError: 401 Client Error: Unauthorized for url: huggingface.co

ID: huggingface/gated-model-unauthorized

Also available as: JSON · Markdown
92%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Attempting to access a gated model without accepting license or providing auth token.

generic

Workarounds

  1. 95% success Accept the model license on the model page, then use auth token
    1. Visit huggingface.co/{model} and accept license. 2. huggingface-cli login. 3. Re-run.

    Sources: https://huggingface.co/docs/transformers/

  2. 90% success Pass token explicitly in from_pretrained
    model = AutoModel.from_pretrained(name, token='hf_xxxxx')
  3. 85% success Set HF_TOKEN environment variable
    export HF_TOKEN=hf_xxxxx  # or add to .env file

Dead Ends

Common approaches that don't work:

  1. Use a mirror site or unofficial copy of the model 85% fail

    Unofficial copies may be tampered with, outdated, or violate the model license

  2. Create a new Hugging Face account to bypass the gate 80% fail

    You still need to accept the license agreement on the new account