Authorization header is correct, but the token seems invalid

Hello,

I read more solutions for this problem, but no one is valid for me.

I use huggingface with nodejs.

Also with a simple code I have the error.

const { HfInference } = require(ā€˜@huggingface/inferenceā€™);

const hf = new HfInference({ token: ā€˜hf_ā€¦ā€™ }); //
await hf.featureExtraction({
model: ā€œsentence-transformers/distilbert-base-nli-mean-tokensā€,
inputs: ā€œThat is a happy personā€,
});

I checked

Write access to contents/settings of all repos under your personal namespace
Make calls to the serverless Inference API

in ther option of the AccessToken

Maybe someone can help me.

1 Like

Iā€™m not familiar with JavaScript, but letā€™s follow the sample anyway. Sometimes a model is bad, so you can try a different one.

Thanks for reply.
I have to use the first model for my solution

1 Like

Solved.
The problem was that I used "const hf ", and this is noa accepted.
I changed in ā€œconst inferenceā€ and now it works.

1 Like