got 401 after grant gated access
#6
by
easychen
- opened
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:
- First get your access tokens (read or write) from: https://huggingface.co./settings/tokens
huggingface-cli login
with your access token.- Then you can load model according to the manual: https://github.com/netease-youdao/BCEmbedding/tree/master?tab=readme-ov-file#quick-start