got 401 after grant gated access

#6
by easychen - opened

Screen Shot 2024-02-04 at 15.48.10.png

with code:

async function query(data) {
    const response = await fetch(
        "https://api-inference.huggingface.co/models/maidalun1020/bce-embedding-base_v1",
        {
            headers: { Authorization: "Bearer write_token" },
            method: "POST",
            body: JSON.stringify(data),
        }
    );
    const result = await response.json();
    return result;
}

query({"inputs": "Today is a sunny day and I will get some ice cream."}).then((response) => {
    console.log(JSON.stringify(response));
});

got error:

{"error":"401 Client Error. (Request ID: Root=1-65bf4101-4e2e911f678fb4b153366678)\n\nCannot access gated repo for url https://huggingface.co./api/models/maidalun1020/bce-embedding-base_v1.\nRepo model maidalun1020/bce-embedding-base_v1 is gated. You must be authenticated to access it."}

Not recommend to use api-inference of hugginface.
You should:

  1. First get your access tokens (read or write) from: https://huggingface.co./settings/tokens
  2. huggingface-cli login with your access token.
  3. Then you can load model according to the manual: https://github.com/netease-youdao/BCEmbedding/tree/master?tab=readme-ov-file#quick-start

Sign up or log in to comment