# Problems obtaining a Bearer API\_TOKEN

**URL:** <https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686>\
**Category:** Beginners\
**Created:** [February 13, 2022, 5:48pm UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686 "2022-02-13T17:48:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToonTalk](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/toontalk/32/4016_2.png) [@ToonTalk](https://discuss.huggingface.co/u/ToonTalk)\
**Post date:** [February 13, 2022, 5:48pm UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686/1 "2022-02-13T17:48:47Z")

</div>

Getting started states:

> - Get your API token [in your Hugging Face profile](https://huggingface.co/settings/token).

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”

---

<div class="post-metadata">

**Author:** ![beneyal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/beneyal/32/27988_2.png) [@beneyal](https://discuss.huggingface.co/u/beneyal)\
**Post date:** [February 14, 2022, 9:14am UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686/2 "2022-02-14T09:14:08Z")

</div>

Hello! 👋

How are you sending your request via `curl`?

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

```auto
$ 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"}]

```

---

<div class="post-metadata">

**Author:** ![ToonTalk](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/toontalk/32/4016_2.png) [@ToonTalk](https://discuss.huggingface.co/u/ToonTalk)\
**Post date:** [February 14, 2022, 9:20am UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686/3 "2022-02-14T09:20:20Z")

</div>

Hi. Thanks.

That’s pretty much what I did:

curl [https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-ru-en](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](https://api-inference.huggingface.co/docs/curl/html/quicktour.html#get-your-api-token) suggests?

---

<div class="post-metadata">

**Author:** ![beneyal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/beneyal/32/27988_2.png) [@beneyal](https://discuss.huggingface.co/u/beneyal)\
**Post date:** [February 14, 2022, 9:23am UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686/4 "2022-02-14T09:23:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ToonTalk](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/toontalk/32/4016_2.png) [@ToonTalk](https://discuss.huggingface.co/u/ToonTalk)\
**Post date:** [February 16, 2022, 4:43pm UTC](https://discuss.huggingface.co/t/problems-obtaining-a-bearer-api-token/14686/5 "2022-02-16T16:43:58Z")

</div>

> [@ToonTalk](#):
>
> `-H "Authorization: Bearer ${hf_P...w}"`

Should have been

-H “Authorization: Bearer hf\_P…w”

Sorry for the trouble.

But perhaps the documentation about the api\_… key should be updated
