Dear Team,
I am currently enrolled in the Agents course and encountered an error while attempting to run the Smol_Agents notebook. Specifically, I received an error when using model=HfApiModel() with my free Hugging Face API key.
Could you please assist me in resolving this issue?
++++++++++++++++++++++++++++++++++++++++++++++++++
Error:
Error in generating model output:
401 Client Error: Unauthorized for url:
router.huggingface.co/hf-inference/models/Qwen/Qwen2.5-Coder-32B-Instruct/v1/chat/completions (Request ID:
Root=1-67dfa1c6-189363a609d7874972942ec5;5bbc6b0b-6f48-455e-b448-e4d5fc570b68)
Invalid credentials in Authorization header
[Step 1: Duration 2.02 seconds]
HTTPError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/huggingface_hub/utils/_http.py in hf_raise_for_status(response, endpoint_name)
408 try:
→ 409 response.raise_for_status()
410 except HTTPError as e:
11 frames
401 Client Error: Unauthorized for url: /static-proxy?url=https%3A%2F%2Frouter.huggingface.co%2Fhf-inference%2Fmodels%2FQwen%2FQwen2.5-Coder-32B-Instruct%2Fv1%2Fchat%2Fcompletions%3C%2Fa%3E%3C%2Fp%3E
The above exception was the direct cause of the following exception:
AgentGenerationError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/smolagents/agents.py in step(self, memory_step)
1200 memory_step.model_output = model_output
1201 except Exception as e:
→ 1202 raise AgentGenerationError(f"Error in generating model output:\n{e}", self.logger) from e
1203
1204 self.logger.log_markdown(
Invalid credentials in Authorization header
++++++++++++++++++++++++++++++++++++++++++++++++
1 Like
Can you confirm if accessing Inference API requires Pro subscription or Free token will work?
2 Likes
I can’t try the Free token at the moment…
The same problem was reported quite a lot in the agents course channel on HF Discord. It would be easier if the following method was still available…
from Discord:
You can use https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud/ as model_id (Qwen 2.5 Coder 32B)
1 Like
huggingface is just sucks
1 Like