Smolagents 401 cliennt error

from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
model = HfApiModel(token=“my_acces_token”)
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
agent.run(“Who won the t20 worldcup 2024”)

I am trying to run the above code and this is the error that i am getting

Error in generating model output:
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%3C%2Fa%3E (Request ID: yW7h4j)

401 Unauthorized

whereas i saw multiple users using the exact same code and making this work for themselves

1 Like

The contents of the token probably do not correspond to Inference. If you do not pass the token, that code will work normally.