#Help for CreateModeration (Node.js - TypeScript)

2 messages · Page 1 of 1 (latest)

lost granite
#

I am in the process of making a Discord bot and I have the openai NPM package installed, however, whenever I call the createModeration from the OpenAI client it throws me an error:
And this is my code:

const checkMessage = async () => {
  const response = await OpenAi.createModeration({     
    model: "text-moderation-001",
    input: message.content
  });
  return response.data.results[0];
};

This is the error:

[17:23:58] ERROR DETECTED [LAUNCHER] Error: Request failed with status code 400
crude bramble
#

Hello!

Status code 400 usually means that the server was unable to understand or process the request sent by the client because the syntax of the request was invalid, incomplete, or malformed. This is typically due to a client-side error.

I've noticed you are using text-moderation-001 as your model. Based on the API reference here (https://platform.openai.com/docs/api-reference/moderations/create) the currently available moderations models are text-moderation-stable and text-moderation-latest. Though you can just omit the model property entirely to use text -moderation-latest by default.

I hope this helps!