我正在尝试使用以下代码在Express NodeJS中向OpenAI API发出请求:
问题在于我一直收到429太多请求的错误。
以下是更多信息:
- API密钥是正确的。 - 当我进入我的openai账户>查看API密钥:它显示该密钥从未被使用过,因此我从未能够进行调用。那么我为什么会收到“太多请求”的错误? - 我已经尝试在函数中实现指数退避,但它没有起作用。
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
organization: "org-Fn2EqsTpiUCTKb8m61wr6H8m",
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
const openai = new OpenAIApi(configuration);
async function callApi() {
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "Say this is a test",
max_tokens: 3000,
temperature: 0,
});
console.log(response.data.choices[0].text);
}
callApi();
问题在于我一直收到429太多请求的错误。
以下是更多信息:
- API密钥是正确的。 - 当我进入我的openai账户>查看API密钥:它显示该密钥从未被使用过,因此我从未能够进行调用。那么我为什么会收到“太多请求”的错误? - 我已经尝试在函数中实现指数退避,但它没有起作用。