#API errors with code 400

2 messages · Page 1 of 1 (latest)

river fern
#

Anyone know why this is erroring in code 400? Im trying to use the api in a discord bot.

        const ai = new OpenAIApi(config);

        const prompt = interaction.options.getString("query", true);
        const completion = await ai.createCompletion({
            engine: "text-davinci-002",
            n: 1,   
            prompt: `Write a response to the message: ${prompt}`,
            
          });

        const response = completion.choices[0].text;
        await interaction.reply(response);```
river fern
#

I fixed