#Using the api endpoint with Axios

1 messages · Page 1 of 1 (latest)

feral tapir
#

So am trying to use the Axios npm package to send a post request to the chatGPT but I get the Respond "Error: Request failed with status code 400"

So what am woundering is that is this right?

const response = await axios.post(
        endpoint,
        {
          prompt: prompt,
          max_tokens: 100,
        },
        {
          headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${apiKey}`,
          },
        }
      );
``` and am using node.js so this is why am question.