# Unauthorized 401

**URL:** <https://discuss.huggingface.co/t/unauthorized-401/141015>\
**Category:** Models\
**Created:** [February 15, 2025, 6:12pm UTC](https://discuss.huggingface.co/t/unauthorized-401/141015 "2025-02-15T18:12:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dragos-bajenaru37](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@dragos-bajenaru37](https://discuss.huggingface.co/u/dragos-bajenaru37)\
**Post date:** [February 15, 2025, 6:12pm UTC](https://discuss.huggingface.co/t/unauthorized-401/141015/1 "2025-02-15T18:12:05Z")

</div>

Hello,  
Can someone help with:

Error in generating tool call with model:  
401 Client Error: Unauthorized for url: [https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions](https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions)  
(Request ID: pM7Zmc)

401 Unauthorized  
[Step 0: Duration 0.54 seconds]

---

<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 15, 2025, 10:52pm UTC](https://discuss.huggingface.co/t/unauthorized-401/141015/2 "2025-02-15T22:52:40Z")

</div>

That’s strange. You don’t need a token to use that model, so authentication errors don’t normally occur.🤔  
Perhaps you’re passing the wrong token when you don’t need to…

---

<div class="post-metadata">

**Author:** ![heena2024](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@heena2024](https://discuss.huggingface.co/u/heena2024)\
**Post date:** [February 22, 2025, 1:12pm UTC](https://discuss.huggingface.co/t/unauthorized-401/141015/3 "2025-02-22T13:12:24Z")

</div>

I am facing the same issue in smol agents first agent template

---

<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 22, 2025, 3:07pm UTC](https://discuss.huggingface.co/t/unauthorized-401/141015/4 "2025-02-22T15:07:06Z")

</div>

from HF Discord:

* * *

> ### posti
> 
> I solved by creating a secret with the api token in the space settings

> ### posti
> 
> On the space settings, go to Variables and secrets, and create a new secret named HF\_TOKEN  
> The value of the secret should be your access token  
> If you need to create an access token, go to your HF profile page  
> On the left menu, go to the access token option  
> Andre’s then the Create new token, on the top right

---

<div class="post-metadata">

**Author:** ![Noumbissi16](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/noumbissi16/32/42021_2.png) [@Noumbissi16](https://discuss.huggingface.co/u/Noumbissi16)\
**Post date:** [February 26, 2025, 11:35am UTC](https://discuss.huggingface.co/t/unauthorized-401/141015/5 "2025-02-26T11:35:58Z")

</div>

Thanks it worked, I always got that error when creating a new space
