我正在尝试构建一个生成图像的不和谐机器人,但我遇到了这个问题。我正在关注 YouTube 上的教程,我希望有人帮助我解决这个问题。
`const { SlashCommandBuilder, EmbedBuilder} = require(`discord.js`);
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: 'My Key'
});
const openai = new OpenAIApi(configuration);`
# I think this is a tough one since its a command building integrated with openai Api
您尝试的代码适用于 OpenAI Node.js SDK <
v4
,但您使用的是 >=v4
。
如果您使用 OpenAI Node.js SDK >=
v4
,以下是正确的初始化:
import OpenAI from "openai";
const openai = new OpenAI(
apiKey: "sk-xxxxxxxxxxxxxxxxxxxxxxxx"
);