API Keys consistently failing with 401 Error

Hello,

I am trying to use the Inference API for public models like mistralai/Mistral-7B-Instruct-v0.2.

I have repeatedly generated brand new API keys with “Inference” permissions, but every API call fails with a 401 Invalid credentials error. I have confirmed my code is correct by running it in a clean Google Colab environment and even hardcoding the key, but the error persists.

Could you please check if there is a restriction or issue with my account that is preventing my API keys from being authorized? My username is Yash12801.

Thank you.

1 Like

mistralai/Mistral-7B-Instruct-v0.2 is a gated model, not public, so try the public model (e.g. HuggingFaceTB/SmolLM3-3B) first. Read tokens are reliable.