Problems obtaining a Bearer API_TOKEN

Getting started states:

You should see a token api_XXXXXXXX or api_org_XXXXXXX .

However, /huggingface.co/settings/token only provides READ and WRITE tokens. Using them produces
{“error”:“Authorization header is invalid, use ‘Bearer API_TOKEN’”}

And the CURL examples state:

“Authorization: Bearer ${HF_API_TOKEN}”

which is what the READ and WRITE tokens start with unlike the api… tokens mentioned in the getting started.

Could this be because I’m current signed up for the free plan. But it states “Try Inference API: CPU
Up to 30k input characters /month”

Hello! :wave:

How are you sending your request via curl?

It should look something like this (for the GPT2 endpoint):

$ curl -X POST "https://api-inference.huggingface.co/models/gpt2" \
       --header "Authorization: Bearer <YOUR READ API TOKEN HERE>" \
       -d '{"inputs": "Hi, my name is "}'

[{"generated_text":"Hi, my name is ive only a few hours away from this game and I have just finished buying a pack of 8 and am not in one of your queue anymore. I have been playing with 2-3 players and am a huge die roll"}]

Hi. Thanks.

That’s pretty much what I did:

curl https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-ru-en \

    -X POST \

    -d '{"inputs": "Меня зовут Вольфганг и я живу в Берлине"}' \

    -H "Authorization: Bearer ${hf_P...w}"

Should my API key start with api_ as the getting started page suggests?

I can tell you my read API key certainly doesn’t start with api_.

Should have been

-H “Authorization: Bearer hf_P…w”

Sorry for the trouble.

But perhaps the documentation about the api_… key should be updated