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.

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

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