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: https://api-inference.huggingface.co/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions (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.