CORS Error When Using HF Interface API with `gemma-2-9b-it`

I’m encountering a CORS-related issue when trying to use the HF Interface API with the google/gemma-2-9b-it model. The problem occurs both when calling the API from JavaScript and when testing directly on the Hugging Face website (google/gemma-2-9b-it · Hugging Face).

Error Details

When making a request from the Hugging Face website, I receive the following error:

Access to fetch at 'https://router.huggingface.co/hf-inference/models/google/gemma-2-9b-it/v1/chat/completions' from origin 'https://huggingface.co' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
https://router.huggingface.co/hf-inference/models/google/gemma-2-9b-it/v1/chat/completions net::ERR_FAILED 503 (Service Unavailable)

Observations

  • The same request works fine with google/gemma-2-2b-it.
  • I’ve encountered a similar issue with another model before, but only when it was cold.
1 Like


Hmm… Maybe server unstable?

1 Like

Interesting. It appears to work well when using Nebius AI Studio as the interface provider. However, there still seems to be an issue when switching to HF-Inference as the provider.

1 Like