Inference API returning 415 error

#215
by javidpl - opened

I am using Bloom model with the Inference API (Javascript) since months without any problem, but since some days it's always returning this error every time I fetch the API:
'the server responded with a status of 415 (Unsupported Media Type)'

The code was not modified at all and works good with other models.
Any idea why is this happening?

Thanks.

I am running into the same issue.

Here is the code I am using to hit the API

    const response = await fetch(
      "https://api-inference.huggingface.co/models/bigscience/bloom",
      {
        headers: {
          Authorization: `Bearer ${process.env.HUGGING_FACE_API_KEY}`,
        },
        method: "POST",
        body: JSON.stringify({
          inputs: "Can you please let us know more details about your ",
        }),
      }
    );

Interestingly, it works if the inputs string is exactly Can you please let us know more details about your (as is shown in the usage example for the model), but not if it's anything else.

For example, if I remove the trailing space at the end from that string and try to use Can you please let us know more details about your, the request fails and I get a 415.

I managed to get it to work by setting the Content-Type header in the request.

reference:
using fetch to make a POST request

    const response = await fetch(
      "https://api-inference.huggingface.co/models/bigscience/bloom",
      {
        headers: {
          "Content-Type": "application/json",
          Authorization: `Bearer ${process.env.HUGGING_FACE_API_KEY}`,
        },
        method: "POST",
        body: JSON.stringify({
          inputs: "Can you guess what my next ",
        }),
      }
    );
christopher changed discussion status to closed

Thank you very much! Yep, the Content-Type was missing in headers.

Sign up or log in to comment