# 401 Error: Invalid Credentials in Authorization Header (Flan-T5-Large Inference API)

**URL:** <https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207>\
**Category:** Beginners\
**Created:** [February 27, 2025, 8:35am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207 "2025-02-27T08:35:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![BugbotAI](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@BugbotAI](https://discuss.huggingface.co/u/BugbotAI)\
**Post date:** [February 27, 2025, 8:35am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/1 "2025-02-27T08:35:50Z")

</div>

I have already done the following:

✅ Created an API token on Hugging Face  
✅ Checked that my token has “Make calls to inference providers” permission  
✅ Tried regenerating a new token and replacing it in my script  
✅ Confirmed that my Hugging Face account is active and not restricted

This is the error message i get: I have already done the following:

This is the error message i get:

import requests

HF\_TOKEN = “JOUW\_NIEUWE\_API\_TOKEN”

API\_URL = “[https://api-inference.huggingface.co/models/google/flan-t5-large](https://api-inference.huggingface.co/models/google/flan-t5-large)”

HEADERS = {“Authorization”: f"Bearer {HF\_TOKEN}"}

response = requests.get(API\_URL, headers=HEADERS)

print(“Response status code:”, response.status\_code)

print(“Response JSON:”, response.json())

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 27, 2025, 9:52am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/2 "2025-02-27T09:52:55Z")

</div>

It works for me.

```auto
Response status code: 200

```

Meybe try:

```auto
pip install -U huggingface_hub

```

---

<div class="post-metadata">

**Author:** ![BugbotAI](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@BugbotAI](https://discuss.huggingface.co/u/BugbotAI)\
**Post date:** [February 27, 2025, 10:13am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/3 "2025-02-27T10:13:23Z")

</div>

Is it possible that it does work only with a pro membership?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 27, 2025, 11:07am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/4 "2025-02-27T11:07:55Z")

</div>

I don’t know… even models that don’t seem to be like that have the same behavior. Maybe the whole thing is buggy.

```py
HF_TOKEN = "my token"
import requests
#API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-large"
API_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-3B"
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"}
response = requests.get(API_URL, headers=HEADERS)
print("Response status code:", response.status_code)
print("Response JSON:", response.json())

```

---

<div class="post-metadata">

**Author:** ![BugbotAI](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@BugbotAI](https://discuss.huggingface.co/u/BugbotAI)\
**Post date:** [February 27, 2025, 11:54am UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/5 "2025-02-27T11:54:47Z")

</div>

You mean the language model might be buggy

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 27, 2025, 2:26pm UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/6 "2025-02-27T14:26:01Z")

</div>

No, not the model itself, but the system of the Hugging Face Inference API. It looks like it’s being renovated.

---

<div class="post-metadata">

**Author:** ![BugbotAI](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@BugbotAI](https://discuss.huggingface.co/u/BugbotAI)\
**Post date:** [February 28, 2025, 12:40pm UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/7 "2025-02-28T12:40:44Z")

</div>

I did all of that but still don’t work if i message me telegram bot it only react on /start but the ai language model doesn’t work

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 28, 2025, 1:14pm UTC](https://discuss.huggingface.co/t/401-error-invalid-credentials-in-authorization-header-flan-t5-large-inference-api/143207/8 "2025-02-28T13:14:37Z")

</div>

Hmm, I don’t know who is in charge.  
[website@huggingface.co](mailto:website@huggingface.co)
