# Unauthorized 401

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%3E%5C
**Category:** Models\
**Created:** [February 15, 2025, 6:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdragos-bajenaru37)%5C
**Post date:** [February 15, 2025, 6:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%2F1 "2025-02-15T18:12:05Z")

</div>

Hello,  
Can someone help with:

Error in generating tool call with model:  
401 Client Error: Unauthorized for url: [/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2FQwen%2FQwen2.5-Coder-32B-Instruct%2Fv1%2Fchat%2Fcompletions%5D(https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2FQwen%2FQwen2.5-Coder-32B-Instruct%2Fv1%2Fchat%2Fcompletions)  
(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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [February 15, 2025, 10:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%2F2 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fheena2024)%5C
**Post date:** [February 22, 2025, 1:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%2F3 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [February 22, 2025, 3:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%2F4 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FNoumbissi16)%5C
**Post date:** [February 26, 2025, 11:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funauthorized-401%2F141015%2F5 "2025-02-26T11:35:58Z")

</div>

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